Pyrogenesis trunk
Classes | Macros | Typedefs | Enumerations | Functions | Variables
mongoose.cpp File Reference
#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/select.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <sys/time.h>
#include <stdint.h>
#include <inttypes.h>
#include <netdb.h>
#include <pwd.h>
#include <unistd.h>
#include <dirent.h>
#include <pthread.h>
#include "mongoose.h"
Include dependency graph for mongoose.cpp:

Classes

struct  ssl_func
 
struct  usa
 
struct  vec
 
struct  mgstat
 
struct  socket
 
struct  mg_context
 
struct  mg_connection
 
struct  MD5Context
 
struct  ah
 
struct  de
 
struct  dir_scan_data
 

Macros

#define __STDC_LIMIT_MACROS
 
#define NO_CGI
 
#define NO_SSL
 
#define _XOPEN_SOURCE   600
 
#define _LARGEFILE_SOURCE
 
#define __STDC_FORMAT_MACROS
 
#define SSL_LIB   "libssl.so"
 
#define CRYPTO_LIB   "libcrypto.so"
 
#define DIRSEP   '/'
 
#define IS_DIRSEP_CHAR(c)   ((c) == '/')
 
#define O_BINARY   0
 
#define closesocket(a)   close(a)
 
#define mg_fopen(x, y)   fopen(x, y)
 
#define mg_mkdir(x, y)   mkdir(x, y)
 
#define mg_remove(x)   remove(x)
 
#define mg_rename(x, y)   rename(x, y)
 
#define ERRNO   errno
 
#define INVALID_SOCKET   (-1)
 
#define INT64_FMT   PRId64
 
#define WINCDECL
 
#define MONGOOSE_VERSION   "3.1"
 
#define PASSWORDS_FILE_NAME   ".htpasswd"
 
#define CGI_ENVIRONMENT_SIZE   4096
 
#define MAX_CGI_ENVIR_VARS   64
 
#define ARRAY_SIZE(array)   (sizeof(array) / sizeof(array[0]))
 
#define DEBUG_TRACE(x)
 
#define SSL_ERROR_WANT_READ   2
 
#define SSL_ERROR_WANT_WRITE   3
 
#define SSL_FILETYPE_PEM   1
 
#define CRYPTO_LOCK   1
 
#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
 
#define SSL_CTX_use_certificate_file
 
#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 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 ENTRIES_PER_CONFIG_OPTION   3
 
#define HEXTOI(x)   (isdigit(x) ? x - '0' : x - 'W')
 
#define F1(x, y, z)   (z ^ (x & (y ^ z)))
 
#define F2(x, y, z)   F1(z, x, y)
 
#define F3(x, y, z)   (x ^ y ^ z)
 
#define F4(x, y, z)   (y ^ (x | ~z))
 
#define MD5STEP(f, w, x, y, z, data, s)    ( w += f(x, y, z) + data, w = w<<s | w>>(32-s), w += x )
 

Typedefs

typedef int SOCKET
 
typedef void *(* mg_thread_func_t) (void *)
 
typedef struct ssl_st SSL
 
typedef struct ssl_method_st SSL_METHOD
 
typedef struct ssl_ctx_st SSL_CTX
 
typedef struct MD5Context MD5_CTX
 

Enumerations

enum  {
  CGI_EXTENSIONS , CGI_ENVIRONMENT , PUT_DELETE_PASSWORDS_FILE , CGI_INTERPRETER ,
  PROTECT_URI , AUTHENTICATION_DOMAIN , SSI_EXTENSIONS , ACCESS_LOG_FILE ,
  SSL_CHAIN_FILE , ENABLE_DIRECTORY_LISTING , ERROR_LOG_FILE , GLOBAL_PASSWORDS_FILE ,
  INDEX_FILES , ENABLE_KEEP_ALIVE , ACCESS_CONTROL_LIST , MAX_REQUEST_SIZE ,
  EXTRA_MIME_TYPES , LISTENING_PORTS , DOCUMENT_ROOT , SSL_CERTIFICATE ,
  NUM_THREADS , RUN_AS_USER , NUM_OPTIONS
}
 

Functions

const char ** mg_get_valid_option_names (void)
 
static void * call_user (struct mg_connection *conn, enum mg_event event)
 
static int get_option_index (const char *name)
 
const char * mg_get_option (const struct mg_context *ctx, const char *name)
 
static void cry (struct mg_connection *conn, const char *fmt,...)
 
static const char * ssl_error (void)
 
static struct mg_connectionfc (struct mg_context *ctx)
 
const char * mg_version (void)
 
static void mg_strlcpy (char *dst, const char *src, size_t n)
 
static int lowercase (const char *s)
 
static 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 int mg_vsnprintf (struct mg_connection *conn, char *buf, size_t buflen, const char *fmt, va_list ap)
 
static int mg_snprintf (struct mg_connection *conn, char *buf, size_t buflen, const char *fmt,...)
 
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_extension (const char *path, const char *ext_list)
 
static int should_keep_alive (const struct mg_connection *conn)
 
static const char * suggest_connection_header (const struct mg_connection *conn)
 
static void send_http_error (struct mg_connection *conn, int status, const char *reason, const char *fmt,...)
 
static int mg_stat (const char *path, struct mgstat *stp)
 
static void set_close_on_exec (int fd)
 
static int start_thread (struct mg_context *ctx, mg_thread_func_t func, void *param)
 
static int set_non_blocking_mode (SOCKET sock)
 
static int64_t push (FILE *fp, SOCKET sock, SSL *ssl, const char *buf, int64_t len)
 
static int pull (FILE *fp, SOCKET sock, SSL *ssl, char *buf, int len)
 
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)
 
int mg_printf (struct mg_connection *conn, const char *fmt,...)
 
static size_t url_decode (const char *src, size_t src_len, char *dst, size_t dst_len, int is_form_url_encoded)
 
int mg_get_var (const char *buf, size_t buf_len, const char *name, char *dst, size_t dst_len)
 
int mg_get_cookie (const struct mg_connection *conn, const char *cookie_name, char *dst, size_t dst_size)
 
static int get_document_root (const struct mg_connection *conn, struct vec *document_root)
 
static void convert_uri_to_file_name (struct mg_connection *conn, const char *uri, char *buf, size_t buf_len)
 
static int sslize (struct mg_connection *conn, int(*func)(SSL *))
 
static struct mg_connectionmg_connect (struct mg_connection *conn, const char *host, int port, int use_ssl)
 
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)
 
static void get_mime_type (struct mg_context *ctx, const char *path, struct vec *vec)
 
static void byteReverse (unsigned char *buf, unsigned longs)
 
static void MD5Init (MD5_CTX *ctx)
 
static void MD5Transform (uint32_t buf[4], uint32_t const in[16])
 
static void MD5Update (MD5_CTX *ctx, unsigned char const *buf, unsigned len)
 
static void MD5Final (unsigned char digest[16], MD5_CTX *ctx)
 
static void bin2str (char *to, const unsigned char *p, size_t len)
 
void mg_md5 (char *buf,...)
 
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 FILE * open_auth_file (struct mg_connection *conn, const char *path)
 
static int parse_auth_header (struct mg_connection *conn, char *buf, size_t buf_size, struct ah *ah)
 
static int authorize (struct mg_connection *conn, FILE *fp)
 
static int check_authorization (struct mg_connection *conn, const char *path)
 
static void send_authorization_request (struct mg_connection *conn)
 
static int is_authorized_for_put (struct mg_connection *conn)
 
int mg_modify_passwords_file (const char *fname, const char *domain, const char *user, const char *pass)
 
static void 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 scan_directory (struct mg_connection *conn, const char *dir, void *data, void(*cb)(struct de *, void *))
 
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, FILE *fp, int64_t len)
 
static int parse_range_header (const char *header, int64_t *a, int64_t *b)
 
static void gmt_time_string (char *buf, size_t buf_len, time_t *t)
 
static void handle_file_request (struct mg_connection *conn, const char *path, struct mgstat *stp)
 
void mg_send_file (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_request (char *buf, struct mg_request_info *ri)
 
static int read_request (FILE *fp, SOCKET sock, SSL *ssl, char *buf, int bufsiz, int *nread)
 
static int substitute_index_file (struct mg_connection *conn, char *path, size_t path_len, struct mgstat *stp)
 
static int is_not_modified (const struct mg_connection *conn, const struct mgstat *stp)
 
static int forward_body_data (struct mg_connection *conn, FILE *fp, SOCKET sock, SSL *ssl)
 
static int put_dir (const char *path)
 
static void put_file (struct mg_connection *conn, const char *path)
 
static void send_ssi_file (struct mg_connection *, const char *, FILE *, int)
 
static void do_ssi_include (struct mg_connection *conn, const char *ssi, char *tag, int include_level)
 
static void do_ssi_exec (struct mg_connection *conn, char *tag)
 
static void handle_ssi_file_request (struct mg_connection *conn, const char *path)
 
static void send_options (struct mg_connection *conn)
 
static void print_props (struct mg_connection *conn, const char *uri, struct mgstat *st)
 
static void print_dav_dir_entry (struct de *de, void *data)
 
static void handle_propfind (struct mg_connection *conn, const char *path, struct mgstat *st)
 
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 void log_header (const struct mg_connection *conn, const char *header, FILE *fp)
 
static void log_access (const struct mg_connection *conn)
 
static int isbyte (int n)
 
static int check_acl (struct mg_context *ctx, const struct usa *usa)
 
static void add_to_set (SOCKET fd, fd_set *set, int *max_fd)
 
static int set_uid_option (struct mg_context *ctx)
 
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 void close_socket_gracefully (SOCKET sock)
 
static void close_connection (struct mg_connection *conn)
 
static void discard_current_request_from_buffer (struct mg_connection *conn)
 
static int parse_url (const char *url, char *host, int *port)
 
static void handle_proxy_request (struct mg_connection *conn)
 
static int is_valid_uri (const char *uri)
 
static void process_new_connection (struct mg_connection *conn)
 
static int consume_socket (struct mg_context *ctx, struct socket *sp)
 
static void worker_thread (struct mg_context *ctx)
 
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 (struct mg_context *ctx)
 
static void free_context (struct mg_context *ctx)
 
void mg_stop (struct mg_context *ctx)
 
struct mg_contextmg_start (mg_callback_t user_callback, void *user_data, const char **options)
 

Variables

static const char * http_500_error = "Internal Server Error"
 
static struct ssl_func ssl_sw []
 
static struct ssl_func crypto_sw []
 
static const char * month_names []
 
static const char * config_options []
 
struct {
   const char *   extension
 
   size_t   ext_len
 
   const char *   mime_type
 
   size_t   mime_type_len
 
builtin_mime_types []
 

Macro Definition Documentation

◆ __STDC_FORMAT_MACROS

#define __STDC_FORMAT_MACROS

◆ __STDC_LIMIT_MACROS

#define __STDC_LIMIT_MACROS

◆ _LARGEFILE_SOURCE

#define _LARGEFILE_SOURCE

◆ _XOPEN_SOURCE

#define _XOPEN_SOURCE   600

◆ ARRAY_SIZE

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

◆ CGI_ENVIRONMENT_SIZE

#define CGI_ENVIRONMENT_SIZE   4096

◆ closesocket

#define closesocket (   a)    close(a)

◆ CRYPTO_LIB

#define CRYPTO_LIB   "libcrypto.so"

◆ CRYPTO_LOCK

#define CRYPTO_LOCK   1

◆ CRYPTO_num_locks

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

◆ CRYPTO_set_id_callback

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

◆ CRYPTO_set_locking_callback

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

◆ DEBUG_TRACE

#define DEBUG_TRACE (   x)

◆ DIRSEP

#define DIRSEP   '/'

◆ ENTRIES_PER_CONFIG_OPTION

#define ENTRIES_PER_CONFIG_OPTION   3

◆ ERR_error_string

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

◆ ERR_get_error

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

◆ ERRNO

#define ERRNO   errno

◆ F1

#define F1 (   x,
  y,
 
)    (z ^ (x & (y ^ z)))

◆ F2

#define F2 (   x,
  y,
 
)    F1(z, x, y)

◆ F3

#define F3 (   x,
  y,
 
)    (x ^ y ^ z)

◆ F4

#define F4 (   x,
  y,
 
)    (y ^ (x | ~z))

◆ HEXTOI

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

◆ INT64_FMT

#define INT64_FMT   PRId64

◆ INVALID_SOCKET

#define INVALID_SOCKET   (-1)

◆ IS_DIRSEP_CHAR

#define IS_DIRSEP_CHAR (   c)    ((c) == '/')

◆ MAX_CGI_ENVIR_VARS

#define MAX_CGI_ENVIR_VARS   64

◆ MD5STEP

#define MD5STEP (   f,
  w,
  x,
  y,
  z,
  data,
 
)     ( w += f(x, y, z) + data, w = w<<s | w>>(32-s), w += x )

◆ mg_fopen

#define mg_fopen (   x,
 
)    fopen(x, y)

◆ mg_mkdir

#define mg_mkdir (   x,
 
)    mkdir(x, y)

◆ mg_remove

#define mg_remove (   x)    remove(x)

◆ mg_rename

#define mg_rename (   x,
 
)    rename(x, y)

◆ MONGOOSE_VERSION

#define MONGOOSE_VERSION   "3.1"

◆ NO_CGI

#define NO_CGI

◆ NO_SSL

#define NO_SSL

◆ O_BINARY

#define O_BINARY   0

◆ PASSWORDS_FILE_NAME

#define PASSWORDS_FILE_NAME   ".htpasswd"

◆ SSL_accept

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

◆ SSL_connect

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

◆ SSL_CTX_free

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

◆ SSL_CTX_new

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

◆ SSL_CTX_set_default_passwd_cb

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

◆ SSL_CTX_use_certificate_chain_file

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

◆ SSL_CTX_use_certificate_file

#define SSL_CTX_use_certificate_file
Value:
(* (int (*)(SSL_CTX *, \
const char *, int)) ssl_sw[12].ptr)
struct ssl_ctx_st SSL_CTX
Definition: mongoose.cpp:309
static struct ssl_func ssl_sw[]
Definition: mongoose.cpp:380
void(* ptr)(void)
Definition: mongoose.cpp:343

◆ SSL_CTX_use_PrivateKey_file

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

◆ SSL_ERROR_WANT_READ

#define SSL_ERROR_WANT_READ   2

◆ SSL_ERROR_WANT_WRITE

#define SSL_ERROR_WANT_WRITE   3

◆ SSL_FILETYPE_PEM

#define SSL_FILETYPE_PEM   1

◆ SSL_free

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

◆ SSL_get_error

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

◆ SSL_LIB

#define SSL_LIB   "libssl.so"

◆ SSL_library_init

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

◆ SSL_load_error_strings

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

◆ SSL_new

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

◆ SSL_read

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

◆ SSL_set_fd

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

◆ SSL_write

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

◆ SSLv23_server_method

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

◆ WINCDECL

#define WINCDECL

Typedef Documentation

◆ MD5_CTX

typedef struct MD5Context MD5_CTX

◆ mg_thread_func_t

typedef void *(* mg_thread_func_t) (void *)

◆ SOCKET

typedef int SOCKET

◆ SSL

typedef struct ssl_st SSL

◆ SSL_CTX

typedef struct ssl_ctx_st SSL_CTX

◆ SSL_METHOD

typedef struct ssl_method_st SSL_METHOD

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
CGI_EXTENSIONS 
CGI_ENVIRONMENT 
PUT_DELETE_PASSWORDS_FILE 
CGI_INTERPRETER 
PROTECT_URI 
AUTHENTICATION_DOMAIN 
SSI_EXTENSIONS 
ACCESS_LOG_FILE 
SSL_CHAIN_FILE 
ENABLE_DIRECTORY_LISTING 
ERROR_LOG_FILE 
GLOBAL_PASSWORDS_FILE 
INDEX_FILES 
ENABLE_KEEP_ALIVE 
ACCESS_CONTROL_LIST 
MAX_REQUEST_SIZE 
EXTRA_MIME_TYPES 
LISTENING_PORTS 
DOCUMENT_ROOT 
SSL_CERTIFICATE 
NUM_THREADS 
RUN_AS_USER 
NUM_OPTIONS 

Function Documentation

◆ accept_new_connection()

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

◆ add_to_set()

static void add_to_set ( SOCKET  fd,
fd_set *  set,
int *  max_fd 
)
static

◆ authorize()

static int authorize ( struct mg_connection conn,
FILE *  fp 
)
static

◆ bin2str()

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

◆ byteReverse()

static void byteReverse ( unsigned char *  buf,
unsigned  longs 
)
static

◆ call_user()

static void * call_user ( struct mg_connection conn,
enum mg_event  event 
)
static

◆ check_acl()

static int check_acl ( struct mg_context ctx,
const struct usa usa 
)
static

◆ check_authorization()

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

◆ 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

◆ close_all_listening_sockets()

static void close_all_listening_sockets ( struct mg_context ctx)
static

◆ close_connection()

static void close_connection ( struct mg_connection conn)
static

◆ close_socket_gracefully()

static void close_socket_gracefully ( SOCKET  sock)
static

◆ compare_dir_entries()

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

◆ consume_socket()

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

◆ convert_uri_to_file_name()

static void convert_uri_to_file_name ( struct mg_connection conn,
const char *  uri,
char *  buf,
size_t  buf_len 
)
static

◆ cry()

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

◆ dir_scan_callback()

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

◆ discard_current_request_from_buffer()

static void discard_current_request_from_buffer ( struct mg_connection conn)
static

◆ do_ssi_exec()

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

◆ do_ssi_include()

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

◆ fc()

static struct mg_connection * fc ( struct mg_context ctx)
static

◆ forward_body_data()

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

◆ free_context()

static void free_context ( struct mg_context ctx)
static

◆ get_document_root()

static int get_document_root ( const struct mg_connection conn,
struct vec document_root 
)
static

◆ get_header()

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

◆ get_mime_type()

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

◆ get_month_index()

static int get_month_index ( const char *  s)
static

◆ get_option_index()

static int get_option_index ( const char *  name)
static

◆ get_request_len()

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

◆ gmt_time_string()

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

◆ handle_directory_request()

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

◆ handle_file_request()

static void handle_file_request ( struct mg_connection conn,
const char *  path,
struct mgstat stp 
)
static

◆ handle_propfind()

static void handle_propfind ( struct mg_connection conn,
const char *  path,
struct mgstat st 
)
static

◆ handle_proxy_request()

static void handle_proxy_request ( struct mg_connection conn)
static

◆ handle_request()

static void handle_request ( struct mg_connection conn)
static

◆ handle_ssi_file_request()

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

◆ is_authorized_for_put()

static int is_authorized_for_put ( struct mg_connection conn)
static

◆ is_not_modified()

static int is_not_modified ( const struct mg_connection conn,
const struct mgstat stp 
)
static

◆ is_valid_http_method()

static int is_valid_http_method ( const char *  method)
static

◆ is_valid_uri()

static int is_valid_uri ( const char *  uri)
static

◆ isbyte()

static int isbyte ( int  n)
static

◆ log_access()

static void log_access ( const struct mg_connection conn)
static

◆ log_header()

static void log_header ( const struct mg_connection conn,
const char *  header,
FILE *  fp 
)
static

◆ lowercase()

static int lowercase ( const char *  s)
static

◆ master_thread()

static void master_thread ( struct mg_context ctx)
static

◆ match_extension()

static int match_extension ( const char *  path,
const char *  ext_list 
)
static

◆ MD5Final()

static void MD5Final ( unsigned char  digest[16],
MD5_CTX ctx 
)
static

◆ MD5Init()

static void MD5Init ( MD5_CTX ctx)
static

◆ MD5Transform()

static void MD5Transform ( uint32_t  buf[4],
uint32_t const  in[16] 
)
static

◆ MD5Update()

static void MD5Update ( MD5_CTX ctx,
unsigned char const *  buf,
unsigned  len 
)
static

◆ mg_connect()

static struct mg_connection * mg_connect ( struct mg_connection conn,
const char *  host,
int  port,
int  use_ssl 
)
static

◆ mg_get_cookie()

int mg_get_cookie ( const struct mg_connection conn,
const char *  cookie_name,
char *  dst,
size_t  dst_size 
)

◆ mg_get_header()

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

◆ mg_get_option()

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

◆ mg_get_valid_option_names()

const char ** mg_get_valid_option_names ( void  )

◆ mg_get_var()

int mg_get_var ( const char *  buf,
size_t  buf_len,
const char *  name,
char *  dst,
size_t  dst_len 
)

◆ mg_md5()

void mg_md5 ( char *  buf,
  ... 
)

◆ mg_modify_passwords_file()

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

◆ mg_printf()

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

◆ mg_read()

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

◆ mg_send_file()

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

◆ mg_snprintf()

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

◆ mg_start()

struct mg_context * mg_start ( mg_callback_t  user_callback,
void *  user_data,
const char **  options 
)

◆ mg_stat()

static int mg_stat ( const char *  path,
struct mgstat stp 
)
static

◆ mg_stop()

void mg_stop ( struct mg_context ctx)

◆ mg_strcasecmp()

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

◆ mg_strdup()

static char * mg_strdup ( const char *  str)
static

◆ mg_strlcpy()

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

◆ mg_strncasecmp()

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

◆ mg_strndup()

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

◆ mg_version()

const char * mg_version ( void  )

◆ mg_vsnprintf()

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

◆ mg_write()

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

◆ next_option()

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

◆ open_auth_file()

static FILE * open_auth_file ( struct mg_connection conn,
const char *  path 
)
static

◆ parse_auth_header()

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

◆ parse_date_string()

static time_t parse_date_string ( const char *  datetime)
static

◆ parse_http_headers()

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

◆ parse_http_request()

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

◆ parse_port_string()

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

◆ parse_range_header()

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

◆ parse_url()

static int parse_url ( const char *  url,
char *  host,
int *  port 
)
static

◆ print_dav_dir_entry()

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

◆ print_dir_entry()

static void print_dir_entry ( struct de de)
static

◆ print_props()

static void print_props ( struct mg_connection conn,
const char *  uri,
struct mgstat st 
)
static

◆ process_new_connection()

static void process_new_connection ( struct mg_connection conn)
static

◆ produce_socket()

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

◆ pull()

static int pull ( FILE *  fp,
SOCKET  sock,
SSL ssl,
char *  buf,
int  len 
)
static

◆ push()

static int64_t push ( FILE *  fp,
SOCKET  sock,
SSL ssl,
const char *  buf,
int64_t  len 
)
static

◆ put_dir()

static int put_dir ( const char *  path)
static

◆ put_file()

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

◆ read_request()

static int read_request ( FILE *  fp,
SOCKET  sock,
SSL ssl,
char *  buf,
int  bufsiz,
int *  nread 
)
static

◆ remove_double_dots_and_double_slashes()

static void remove_double_dots_and_double_slashes ( char *  s)
static

◆ reset_per_request_attributes()

static void reset_per_request_attributes ( struct mg_connection conn)
static

◆ scan_directory()

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

◆ send_authorization_request()

static void send_authorization_request ( struct mg_connection conn)
static

◆ send_file_data()

static void send_file_data ( struct mg_connection conn,
FILE *  fp,
int64_t  len 
)
static

◆ send_http_error()

static void send_http_error ( struct mg_connection conn,
int  status,
const char *  reason,
const char *  fmt,
  ... 
)
static

◆ send_options()

static void send_options ( struct mg_connection conn)
static

◆ send_ssi_file()

static void send_ssi_file ( struct mg_connection conn,
const char *  path,
FILE *  fp,
int  include_level 
)
static

◆ set_acl_option()

static int set_acl_option ( struct mg_context ctx)
static

◆ set_close_on_exec()

static void set_close_on_exec ( int  fd)
static

◆ set_gpass_option()

static int set_gpass_option ( struct mg_context ctx)
static

◆ set_non_blocking_mode()

static int set_non_blocking_mode ( SOCKET  sock)
static

◆ set_ports_option()

static int set_ports_option ( struct mg_context ctx)
static

◆ set_uid_option()

static int set_uid_option ( struct mg_context ctx)
static

◆ should_keep_alive()

static int should_keep_alive ( const struct mg_connection conn)
static

◆ skip()

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

◆ skip_quoted()

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

◆ ssl_error()

static const char * ssl_error ( void  )
static

◆ sslize()

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

◆ start_thread()

static int start_thread ( struct mg_context ctx,
mg_thread_func_t  func,
void *  param 
)
static

◆ substitute_index_file()

static int substitute_index_file ( struct mg_connection conn,
char *  path,
size_t  path_len,
struct mgstat stp 
)
static

◆ suggest_connection_header()

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

◆ url_decode()

static size_t url_decode ( const char *  src,
size_t  src_len,
char *  dst,
size_t  dst_len,
int  is_form_url_encoded 
)
static

◆ url_encode()

static void url_encode ( const char *  src,
char *  dst,
size_t  dst_len 
)
static

◆ worker_thread()

static void worker_thread ( struct mg_context ctx)
static

Variable Documentation

◆ 

const struct { ... } builtin_mime_types[]

◆ config_options

const char* config_options[]
static
Initial value:
= {
"C", "cgi_extensions", ".cgi,.pl,.php",
"E", "cgi_environment", NULL,
"G", "put_delete_passwords_file", NULL,
"I", "cgi_interpreter", NULL,
"P", "protect_uri", NULL,
"R", "authentication_domain", "mydomain.com",
"S", "ssi_extensions", ".shtml,.shtm",
"a", "access_log_file", NULL,
"c", "ssl_chain_file", NULL,
"d", "enable_directory_listing", "yes",
"e", "error_log_file", NULL,
"g", "global_passwords_file", NULL,
"i", "index_files", "index.html,index.htm,index.cgi",
"k", "enable_keep_alive", "no",
"l", "access_control_list", NULL,
"M", "max_request_size", "16384",
"m", "extra_mime_types", NULL,
"p", "listening_ports", "8080",
"r", "document_root", ".",
"s", "ssl_certificate", NULL,
"t", "num_threads", "10",
"u", "run_as_user", NULL,
NULL
}

◆ 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},
{NULL, NULL}
}

◆ ext_len

size_t ext_len

◆ extension

const char* extension

◆ http_500_error

const char* http_500_error = "Internal Server Error"
static

◆ mime_type

const char* mime_type

◆ mime_type_len

size_t mime_type_len

◆ month_names

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

◆ ssl_sw

struct ssl_func ssl_sw[]
static
Initial value:
= {
{"SSL_free", NULL},
{"SSL_accept", NULL},
{"SSL_connect", NULL},
{"SSL_read", NULL},
{"SSL_write", NULL},
{"SSL_get_error", NULL},
{"SSL_set_fd", NULL},
{"SSL_new", NULL},
{"SSL_CTX_new", NULL},
{"SSLv23_server_method", NULL},
{"SSL_library_init", NULL},
{"SSL_CTX_use_PrivateKey_file", NULL},
{"SSL_CTX_use_certificate_file",NULL},
{"SSL_CTX_set_default_passwd_cb",NULL},
{"SSL_CTX_free", NULL},
{"SSL_load_error_strings", NULL},
{"SSL_CTX_use_certificate_chain_file", NULL},
{NULL, NULL}
}