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 (register char *dst, register 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

#define __STDC_FORMAT_MACROS
#define __STDC_LIMIT_MACROS
#define _LARGEFILE_SOURCE
#define _XOPEN_SOURCE   600
#define ARRAY_SIZE (   array)    (sizeof(array) / sizeof(array[0]))
#define CGI_ENVIRONMENT_SIZE   4096
#define closesocket (   a)    close(a)
#define CRYPTO_LIB   "libcrypto.so"
#define CRYPTO_LOCK   1
#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 (   x)
#define DIRSEP   '/'
#define ENTRIES_PER_CONFIG_OPTION   3
#define ERR_error_string   (* (char * (*)(unsigned long,char *)) crypto_sw[4].ptr)
#define ERR_get_error   (* (unsigned long (*)(void)) crypto_sw[3].ptr)
#define ERRNO   errno
#define F1 (   x,
  y,
 
)    (z ^ (x & (y ^ z)))
#define F2 (   x,
  y,
 
)    F1(z, x, y)
#define F3 (   x,
  y,
 
)    (x ^ y ^ z)
#define F4 (   x,
  y,
 
)    (y ^ (x | ~z))
#define HEXTOI (   x)    (isdigit(x) ? x - '0' : x - 'W')
#define INT64_FMT   PRId64
#define INVALID_SOCKET   (-1)
#define IS_DIRSEP_CHAR (   c)    ((c) == '/')
#define MAX_CGI_ENVIR_VARS   64
#define MD5STEP (   f,
  w,
  x,
  y,
  z,
  data,
 
)    ( w += f(x, y, z) + data, w = w<<s | w>>(32-s), w += x )
#define mg_fopen (   x,
 
)    fopen(x, y)
#define mg_mkdir (   x,
 
)    mkdir(x, y)
#define mg_remove (   x)    remove(x)
#define mg_rename (   x,
 
)    rename(x, y)
#define MONGOOSE_VERSION   "3.1"
#define NO_CGI
#define NO_SSL
#define O_BINARY   0
#define PASSWORDS_FILE_NAME   ".htpasswd"
#define SSL_accept   (* (int (*)(SSL *)) ssl_sw[1].ptr)
#define SSL_connect   (* (int (*)(SSL *)) ssl_sw[2].ptr)
#define SSL_CTX_free   (* (void (*)(SSL_CTX *)) ssl_sw[14].ptr)
#define SSL_CTX_new   (* (SSL_CTX * (*)(SSL_METHOD *)) ssl_sw[8].ptr)
#define SSL_CTX_set_default_passwd_cb   (* (void (*)(SSL_CTX *, mg_callback_t)) ssl_sw[13].ptr)
#define SSL_CTX_use_certificate_chain_file   (* (int (*)(SSL_CTX *, const char *)) ssl_sw[16].ptr)
#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:301
static struct ssl_func ssl_sw[]
Definition: mongoose.cpp:372
void(* ptr)(void)
Definition: mongoose.cpp:335
#define SSL_CTX_use_PrivateKey_file
Value:
(* (int (*)(SSL_CTX *, \
const char *, int)) ssl_sw[11].ptr)
struct ssl_ctx_st SSL_CTX
Definition: mongoose.cpp:301
static struct ssl_func ssl_sw[]
Definition: mongoose.cpp:372
void(* ptr)(void)
Definition: mongoose.cpp:335
#define SSL_ERROR_WANT_READ   2
#define SSL_ERROR_WANT_WRITE   3
#define SSL_FILETYPE_PEM   1
#define SSL_free   (* (void (*)(SSL *)) ssl_sw[0].ptr)
#define SSL_get_error   (* (int (*)(SSL *, int)) ssl_sw[5].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_read   (* (int (*)(SSL *, void *, int)) ssl_sw[3].ptr)
#define SSL_set_fd   (* (int (*)(SSL *, SOCKET)) ssl_sw[6].ptr)
#define SSL_write   (* (int (*)(SSL *, const void *,int)) ssl_sw[4].ptr)
#define SSLv23_server_method   (* (SSL_METHOD * (*)(void)) ssl_sw[9].ptr)
#define WINCDECL

Typedef Documentation

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

Enumeration Type Documentation

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

static void accept_new_connection ( const struct socket listener,
struct mg_context ctx 
)
static
static void add_to_set ( SOCKET  fd,
fd_set *  set,
int *  max_fd 
)
static
static int authorize ( struct mg_connection conn,
FILE *  fp 
)
static
static void bin2str ( char *  to,
const unsigned char *  p,
size_t  len 
)
static
static void byteReverse ( unsigned char *  buf,
unsigned  longs 
)
static
static void* call_user ( struct mg_connection conn,
enum mg_event  event 
)
static
static int check_acl ( struct mg_context ctx,
const struct usa usa 
)
static
static int check_authorization ( struct mg_connection conn,
const char *  path 
)
static
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
static void close_all_listening_sockets ( struct mg_context ctx)
static
static void close_connection ( struct mg_connection conn)
static
static void close_socket_gracefully ( SOCKET  sock)
static
static int WINCDECL compare_dir_entries ( const void *  p1,
const void *  p2 
)
static
static int consume_socket ( struct mg_context ctx,
struct socket sp 
)
static
static void convert_uri_to_file_name ( struct mg_connection conn,
const char *  uri,
char *  buf,
size_t  buf_len 
)
static
static void cry ( struct mg_connection conn,
const char *  fmt,
  ... 
)
static
static void dir_scan_callback ( struct de de,
void *  data 
)
static
static void discard_current_request_from_buffer ( struct mg_connection conn)
static
static void do_ssi_exec ( struct mg_connection conn,
char *  tag 
)
static
static void do_ssi_include ( struct mg_connection conn,
const char *  ssi,
char *  tag,
int  include_level 
)
static
static struct mg_connection* fc ( struct mg_context ctx)
static
static int forward_body_data ( struct mg_connection conn,
FILE *  fp,
SOCKET  sock,
SSL ssl 
)
static
static void free_context ( struct mg_context ctx)
static
static int get_document_root ( const struct mg_connection conn,
struct vec document_root 
)
static
static const char* get_header ( const struct mg_request_info ri,
const char *  name 
)
static
static void get_mime_type ( struct mg_context ctx,
const char *  path,
struct vec vec 
)
static
static int get_month_index ( const char *  s)
static
static int get_option_index ( const char *  name)
static
static int get_request_len ( const char *  buf,
int  buflen 
)
static
static void gmt_time_string ( char *  buf,
size_t  buf_len,
time_t *  t 
)
static
static void handle_directory_request ( struct mg_connection conn,
const char *  dir 
)
static
static void handle_file_request ( struct mg_connection conn,
const char *  path,
struct mgstat stp 
)
static
static void handle_propfind ( struct mg_connection conn,
const char *  path,
struct mgstat st 
)
static
static void handle_proxy_request ( struct mg_connection conn)
static
static void handle_request ( struct mg_connection conn)
static
static void handle_ssi_file_request ( struct mg_connection conn,
const char *  path 
)
static
static int is_authorized_for_put ( struct mg_connection conn)
static
static int is_not_modified ( const struct mg_connection conn,
const struct mgstat stp 
)
static
static int is_valid_http_method ( const char *  method)
static
static int is_valid_uri ( const char *  uri)
static
static int isbyte ( int  n)
static
static void log_access ( const struct mg_connection conn)
static
static void log_header ( const struct mg_connection conn,
const char *  header,
FILE *  fp 
)
static
static int lowercase ( const char *  s)
static
static void master_thread ( struct mg_context ctx)
static
static int match_extension ( const char *  path,
const char *  ext_list 
)
static
static void MD5Final ( unsigned char  digest[16],
MD5_CTX ctx 
)
static
static void MD5Init ( MD5_CTX ctx)
static
static void MD5Transform ( uint32_t  buf[4],
uint32_t const  in[16] 
)
static
static void MD5Update ( MD5_CTX ctx,
unsigned char const *  buf,
unsigned  len 
)
static
static struct mg_connection* mg_connect ( struct mg_connection conn,
const char *  host,
int  port,
int  use_ssl 
)
static
int mg_get_cookie ( const struct mg_connection conn,
const char *  cookie_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 
)
const char** mg_get_valid_option_names ( void  )
int mg_get_var ( const char *  buf,
size_t  buf_len,
const char *  name,
char *  dst,
size_t  dst_len 
)
void mg_md5 ( char *  buf,
  ... 
)
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 
)
void mg_send_file ( struct mg_connection conn,
const char *  path 
)
static int mg_snprintf ( struct mg_connection conn,
char *  buf,
size_t  buflen,
const char *  fmt,
  ... 
)
static
struct mg_context* mg_start ( mg_callback_t  user_callback,
void *  user_data,
const char **  options 
)
static int mg_stat ( const char *  path,
struct mgstat stp 
)
static
void mg_stop ( struct mg_context ctx)
static int mg_strcasecmp ( const char *  s1,
const char *  s2 
)
static
static char* mg_strdup ( const char *  str)
static
static void mg_strlcpy ( register char *  dst,
register const char *  src,
size_t  n 
)
static
static int mg_strncasecmp ( const char *  s1,
const char *  s2,
size_t  len 
)
static
static char* mg_strndup ( const char *  ptr,
size_t  len 
)
static
const char* mg_version ( void  )
static int mg_vsnprintf ( struct mg_connection conn,
char *  buf,
size_t  buflen,
const char *  fmt,
va_list  ap 
)
static
int mg_write ( struct mg_connection conn,
const void *  buf,
size_t  len 
)
static const char* next_option ( const char *  list,
struct vec val,
struct vec eq_val 
)
static
static FILE* open_auth_file ( struct mg_connection conn,
const char *  path 
)
static
static int parse_auth_header ( struct mg_connection conn,
char *  buf,
size_t  buf_size,
struct ah ah 
)
static
static time_t parse_date_string ( const char *  datetime)
static
static void parse_http_headers ( char **  buf,
struct mg_request_info ri 
)
static
static int parse_http_request ( char *  buf,
struct mg_request_info ri 
)
static
static int parse_port_string ( const struct vec vec,
struct socket so 
)
static
static int parse_range_header ( const char *  header,
int64_t a,
int64_t b 
)
static
static int parse_url ( const char *  url,
char *  host,
int *  port 
)
static
static void print_dav_dir_entry ( struct de de,
void *  data 
)
static
static void print_dir_entry ( struct de de)
static
static void print_props ( struct mg_connection conn,
const char *  uri,
struct mgstat st 
)
static
static void process_new_connection ( struct mg_connection conn)
static
static void produce_socket ( struct mg_context ctx,
const struct socket sp 
)
static
static int pull ( FILE *  fp,
SOCKET  sock,
SSL ssl,
char *  buf,
int  len 
)
static
static int64_t push ( FILE *  fp,
SOCKET  sock,
SSL ssl,
const char *  buf,
int64_t  len 
)
static
static int put_dir ( const char *  path)
static
static void put_file ( struct mg_connection conn,
const char *  path 
)
static
static int read_request ( FILE *  fp,
SOCKET  sock,
SSL ssl,
char *  buf,
int  bufsiz,
int *  nread 
)
static
static void remove_double_dots_and_double_slashes ( char *  s)
static
static void reset_per_request_attributes ( struct mg_connection conn)
static
static int scan_directory ( struct mg_connection conn,
const char *  dir,
void *  data,
void(*)(struct de *, void *)  cb 
)
static
static void send_authorization_request ( struct mg_connection conn)
static
static void send_file_data ( struct mg_connection conn,
FILE *  fp,
int64_t  len 
)
static
static void send_http_error ( struct mg_connection conn,
int  status,
const char *  reason,
const char *  fmt,
  ... 
)
static
static void send_options ( struct mg_connection conn)
static
static void send_ssi_file ( struct mg_connection conn,
const char *  path,
FILE *  fp,
int  include_level 
)
static
static int set_acl_option ( struct mg_context ctx)
static
static void set_close_on_exec ( int  fd)
static
static int set_gpass_option ( struct mg_context ctx)
static
static int set_non_blocking_mode ( SOCKET  sock)
static
static int set_ports_option ( struct mg_context ctx)
static
static int set_uid_option ( struct mg_context ctx)
static
static int should_keep_alive ( const struct mg_connection conn)
static
static char* skip ( char **  buf,
const char *  delimiters 
)
static
static char* skip_quoted ( char **  buf,
const char *  delimiters,
const char *  whitespace,
char  quotechar 
)
static
static const char* ssl_error ( void  )
static
static int sslize ( struct mg_connection conn,
int(*)(SSL *)  func 
)
static
static int start_thread ( struct mg_context ctx,
mg_thread_func_t  func,
void *  param 
)
static
static int substitute_index_file ( struct mg_connection conn,
char *  path,
size_t  path_len,
struct mgstat stp 
)
static
static const char* suggest_connection_header ( const struct mg_connection conn)
static
static size_t url_decode ( const char *  src,
size_t  src_len,
char *  dst,
size_t  dst_len,
int  is_form_url_encoded 
)
static
static void url_encode ( const char *  src,
char *  dst,
size_t  dst_len 
)
static
static void worker_thread ( struct mg_context ctx)
static

Variable Documentation

const { ... } builtin_mime_types[]
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
}
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}
}
size_t ext_len
const char* extension
const char* http_500_error = "Internal Server Error"
static
const char* mime_type
size_t mime_type_len
const char* month_names[]
static
Initial value:
= {
"Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
}
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}
}