Classes | Macros | Typedefs | Enumerations | Functions | Variables
mongoose.c 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 <dlfcn.h>
#include <pthread.h>
#include "mongoose.h"
Include dependency graph for mongoose.c:

Go to the source code of this file.

Classes

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

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 *)) ssl_sw[4].ptr)
 
#define ERR_get_error   (* (unsigned long (*)(void)) ssl_sw[3].ptr)
 
#define ERRNO   errno
 
#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 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, s)   ( w += f(x, y, z) + data, w = w<<s | w>>(32-s), w += x )
 
#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 MONGOOSE_VERSION   "3.0"
 
#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
 
#define SSL_CTX_use_PrivateKey_file
 
#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])
 
#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
 

Typedefs

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
 

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, MAX_THREADS, NUM_OPTIONS
}
 

Functions

static void accept_new_connection (const struct socket *listener, struct mg_context *ctx)
 
static void add_to_set (SOCKET fd, fd_set *set, int *max_fd)
 
static char * addenv (struct cgi_env_block *block, const char *fmt,...)
 
static int authorize (struct mg_connection *conn, FILE *fp)
 
static void bin2str (char *to, const unsigned char *p, size_t len)
 
static void byteReverse (unsigned char *buf, unsigned longs)
 
static void * call_user (struct mg_connection *conn, enum mg_event event)
 
static int check_acl (struct mg_context *ctx, const struct usa *usa)
 
static int check_authorization (struct mg_connection *conn, const char *path)
 
static int check_password (const char *method, const char *ha1, const char *uri, const char *nonce, const char *nc, const char *cnonce, const char *qop, const char *response)
 
static void close_all_listening_sockets (struct mg_context *ctx)
 
static void close_connection (struct mg_connection *conn)
 
static void close_socket_gracefully (SOCKET sock)
 
static int WINCDECL compare_dir_entries (const void *p1, const void *p2)
 
static int consume_socket (struct mg_context *ctx, struct socket *sp)
 
static void convert_uri_to_file_name (struct mg_connection *conn, const char *uri, char *buf, size_t buf_len)
 
static void cry (struct mg_connection *conn, const char *fmt,...)
 
static void discard_current_request_from_buffer (struct mg_connection *conn)
 
static void do_ssi_exec (struct mg_connection *conn, char *tag)
 
static void do_ssi_include (struct mg_connection *conn, const char *ssi, char *tag, int include_level)
 
static struct mg_connectionfc (struct mg_context *ctx)
 
static int forward_body_data (struct mg_connection *conn, FILE *fp, SOCKET sock, SSL *ssl)
 
static void free_context (struct mg_context *ctx)
 
static int get_document_root (const struct mg_connection *conn, struct vec *document_root)
 
static const char * get_header (const struct mg_request_info *ri, const char *name)
 
static void get_mime_type (struct mg_context *ctx, const char *path, struct vec *vec)
 
static int get_option_index (const char *name)
 
static int get_request_len (const char *buf, int buflen)
 
static void handle_cgi_request (struct mg_connection *conn, const char *prog)
 
static void handle_directory_request (struct mg_connection *conn, const char *dir)
 
static void handle_file_request (struct mg_connection *conn, const char *path, struct mgstat *stp)
 
static void handle_proxy_request (struct mg_connection *conn)
 
static void handle_request (struct mg_connection *conn)
 
static void handle_ssi_file_request (struct mg_connection *conn, const char *path)
 
static int is_authorized_for_put (struct mg_connection *conn)
 
static int is_not_modified (const struct mg_connection *conn, const struct mgstat *stp)
 
static int is_valid_http_method (const char *method)
 
static int is_valid_uri (const char *uri)
 
static int isbyte (int n)
 
static int load_dll (struct mg_context *ctx, const char *dll_name, struct ssl_func *sw)
 
static void log_access (const struct mg_connection *conn)
 
static void log_header (const struct mg_connection *conn, const char *header, FILE *fp)
 
static int lowercase (const char *s)
 
static void master_thread (struct mg_context *ctx)
 
static int match_extension (const char *path, const char *ext_list)
 
static void MD5Final (unsigned char digest[16], MD5_CTX *ctx)
 
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 struct mg_connectionmg_connect (struct mg_connection *conn, const char *host, int port, int use_ssl)
 
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 (struct mg_context *ctx, const char *fname, const char *user, const char *pass)
 
int mg_printf (struct mg_connection *conn, const char *fmt,...)
 
int mg_read (struct mg_connection *conn, void *buf, size_t len)
 
static int mg_snprintf (struct mg_connection *conn, char *buf, size_t buflen, const char *fmt,...)
 
struct mg_contextmg_start (mg_callback_t user_callback, void *user_data, const char **options)
 
static int mg_stat (const char *path, struct mgstat *stp)
 
void mg_stop (struct mg_context *ctx)
 
static int mg_strcasecmp (const char *s1, const char *s2)
 
static char * mg_strdup (const char *str)
 
static void mg_strlcpy (register char *dst, register const char *src, size_t n)
 
static int mg_strncasecmp (const char *s1, const char *s2, size_t len)
 
static char * mg_strndup (const char *ptr, size_t len)
 
const char * mg_version (void)
 
static int mg_vsnprintf (struct mg_connection *conn, char *buf, size_t buflen, const char *fmt, va_list ap)
 
int mg_write (struct mg_connection *conn, const void *buf, size_t len)
 
static int month_number_to_month_name (const char *s)
 
static const char * next_option (const char *list, struct vec *val, struct vec *eq_val)
 
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 time_t parse_date_string (const char *s)
 
static void parse_http_headers (char **buf, struct mg_request_info *ri)
 
static int parse_http_request (char *buf, struct mg_request_info *ri)
 
static int parse_port_string (const struct vec *vec, struct socket *so)
 
static int parse_range_header (const char *header, int64_t *a, int64_t *b)
 
static int parse_url (const char *url, char *host, int *port)
 
static void prepare_cgi_environment (struct mg_connection *conn, const char *prog, struct cgi_env_block *blk)
 
static void print_dir_entry (struct de *de)
 
static void process_new_connection (struct mg_connection *conn)
 
static void produce_socket (struct mg_context *ctx, const struct socket *sp)
 
static int pull (FILE *fp, SOCKET sock, SSL *ssl, char *buf, int len)
 
static int64_t push (FILE *fp, SOCKET sock, SSL *ssl, const char *buf, int64_t len)
 
static int put_dir (const char *path)
 
static void put_file (struct mg_connection *conn, const char *path)
 
static int read_request (FILE *fp, SOCKET sock, SSL *ssl, char *buf, int bufsiz, int *nread)
 
static void remove_double_dots_and_double_slashes (char *s)
 
static void reset_per_request_attributes (struct mg_connection *conn)
 
static void send_authorization_request (struct mg_connection *conn)
 
static void send_file_data (struct mg_connection *conn, FILE *fp, int64_t len)
 
static void send_http_error (struct mg_connection *conn, int status, const char *reason, const char *fmt,...)
 
static void send_ssi_file (struct mg_connection *, const char *, FILE *, int)
 
static int set_acl_option (struct mg_context *ctx)
 
static void set_close_on_exec (int fd)
 
static int set_gpass_option (struct mg_context *ctx)
 
static int set_non_blocking_mode (SOCKET sock)
 
static int set_ports_option (struct mg_context *ctx)
 
static int set_ssl_option (struct mg_context *ctx)
 
static int set_uid_option (struct mg_context *ctx)
 
static int should_keep_alive (const struct mg_connection *conn)
 
static char * skip (char **buf, const char *delimiters)
 
static char * skip_quoted (char **buf, const char *delimiters, const char *whitespace, char quotechar)
 
static pid_t spawn_process (struct mg_connection *conn, const char *prog, char *envblk, char *envp[], int fd_stdin, int fd_stdout, const char *dir)
 
static const char * ssl_error (void)
 
static unsigned long ssl_id_callback (void)
 
static void ssl_locking_callback (int mode, int mutex_num, const char *file, int line)
 
static int sslize (struct mg_connection *conn, int(*func)(SSL *))
 
static int start_thread (struct mg_context *ctx, mg_thread_func_t func, void *param)
 
static int substitute_index_file (struct mg_connection *conn, char *path, size_t path_len, struct mgstat *stp)
 
static const char * suggest_connection_header (const struct mg_connection *conn)
 
static size_t url_decode (const char *src, size_t src_len, char *dst, size_t dst_len, int is_form_url_encoded)
 
static void url_encode (const char *src, char *dst, size_t dst_len)
 
static void worker_thread (struct mg_context *ctx)
 

Variables

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

Macro Definition Documentation

#define _LARGEFILE_SOURCE

Definition at line 25 of file mongoose.c.

#define _XOPEN_SOURCE   600

Definition at line 24 of file mongoose.c.

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

Definition at line 213 of file mongoose.c.

#define CGI_ENVIRONMENT_SIZE   4096

Definition at line 211 of file mongoose.c.

#define closesocket (   a)    close(a)

Definition at line 194 of file mongoose.c.

#define CRYPTO_LIB   "libcrypto.so"

Definition at line 188 of file mongoose.c.

#define CRYPTO_LOCK   1

Definition at line 249 of file mongoose.c.

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

Definition at line 303 of file mongoose.c.

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

Definition at line 306 of file mongoose.c.

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

Definition at line 304 of file mongoose.c.

#define DEBUG_TRACE (   x)

Definition at line 227 of file mongoose.c.

#define DIRSEP   '/'

Definition at line 191 of file mongoose.c.

#define ENTRIES_PER_CONFIG_OPTION   3

Definition at line 423 of file mongoose.c.

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

Definition at line 309 of file mongoose.c.

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

Definition at line 308 of file mongoose.c.

#define ERRNO   errno

Definition at line 199 of file mongoose.c.

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

Definition at line 1818 of file mongoose.c.

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

Definition at line 1819 of file mongoose.c.

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

Definition at line 1820 of file mongoose.c.

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

Definition at line 1821 of file mongoose.c.

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

Definition at line 201 of file mongoose.c.

#define INVALID_SOCKET   (-1)

Definition at line 200 of file mongoose.c.

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

Definition at line 192 of file mongoose.c.

#define MAX_CGI_ENVIR_VARS   64

Definition at line 212 of file mongoose.c.

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

Definition at line 1823 of file mongoose.c.

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

Definition at line 195 of file mongoose.c.

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

Definition at line 196 of file mongoose.c.

#define mg_remove (   x)    remove(x)

Definition at line 197 of file mongoose.c.

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

Definition at line 198 of file mongoose.c.

#define MONGOOSE_VERSION   "3.0"

Definition at line 209 of file mongoose.c.

#define O_BINARY   0

Definition at line 193 of file mongoose.c.

#define PASSWORDS_FILE_NAME   ".htpasswd"

Definition at line 210 of file mongoose.c.

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

Definition at line 282 of file mongoose.c.

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

Definition at line 283 of file mongoose.c.

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

Definition at line 298 of file mongoose.c.

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

Definition at line 289 of file mongoose.c.

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

Definition at line 296 of file mongoose.c.

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

Definition at line 300 of file mongoose.c.

#define SSL_CTX_use_certificate_file
Value:
(* (int (*)(SSL_CTX *, \
const char *, int)) ssl_sw[12].ptr)
static struct ssl_func ssl_sw[]
Definition: mongoose.c:315
struct ssl_ctx_st SSL_CTX
Definition: mongoose.c:244
void(* ptr)(void)
Definition: mongoose.c:278

Definition at line 294 of file mongoose.c.

#define SSL_CTX_use_PrivateKey_file
Value:
(* (int (*)(SSL_CTX *, \
const char *, int)) ssl_sw[11].ptr)
static struct ssl_func ssl_sw[]
Definition: mongoose.c:315
struct ssl_ctx_st SSL_CTX
Definition: mongoose.c:244
void(* ptr)(void)
Definition: mongoose.c:278

Definition at line 292 of file mongoose.c.

#define SSL_ERROR_WANT_READ   2

Definition at line 246 of file mongoose.c.

#define SSL_ERROR_WANT_WRITE   3

Definition at line 247 of file mongoose.c.

#define SSL_FILETYPE_PEM   1

Definition at line 248 of file mongoose.c.

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

Definition at line 281 of file mongoose.c.

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

Definition at line 286 of file mongoose.c.

#define SSL_LIB   "libssl.so"

Definition at line 185 of file mongoose.c.

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

Definition at line 291 of file mongoose.c.

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

Definition at line 299 of file mongoose.c.

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

Definition at line 288 of file mongoose.c.

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

Definition at line 284 of file mongoose.c.

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

Definition at line 287 of file mongoose.c.

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

Definition at line 285 of file mongoose.c.

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

Definition at line 290 of file mongoose.c.

#define WINCDECL

Definition at line 203 of file mongoose.c.

Typedef Documentation

typedef struct MD5Context MD5_CTX
typedef void*(* mg_thread_func_t) (void *)

Definition at line 235 of file mongoose.c.

typedef int SOCKET

Definition at line 202 of file mongoose.c.

typedef struct ssl_st SSL

Definition at line 242 of file mongoose.c.

typedef struct ssl_ctx_st SSL_CTX

Definition at line 244 of file mongoose.c.

typedef struct ssl_method_st SSL_METHOD

Definition at line 243 of file mongoose.c.

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 
MAX_THREADS 
NUM_OPTIONS 

Definition at line 386 of file mongoose.c.

Function Documentation

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

Definition at line 3955 of file mongoose.c.

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

Definition at line 3477 of file mongoose.c.

static char* addenv ( struct cgi_env_block block,
const char *  fmt,
  ... 
)
static

Definition at line 2760 of file mongoose.c.

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

Definition at line 2148 of file mongoose.c.

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

Definition at line 1987 of file mongoose.c.

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

Definition at line 1807 of file mongoose.c.

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

Definition at line 468 of file mongoose.c.

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

Definition at line 3431 of file mongoose.c.

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

Definition at line 2174 of file mongoose.c.

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

Definition at line 2017 of file mongoose.c.

static void close_all_listening_sockets ( struct mg_context ctx)
static

Definition at line 3288 of file mongoose.c.

static void close_connection ( struct mg_connection conn)
static

Definition at line 3674 of file mongoose.c.

static void close_socket_gracefully ( SOCKET  sock)
static

Definition at line 3653 of file mongoose.c.

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

Definition at line 2360 of file mongoose.c.

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

Definition at line 3836 of file mongoose.c.

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

Definition at line 1556 of file mongoose.c.

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

Definition at line 498 of file mongoose.c.

static void discard_current_request_from_buffer ( struct mg_connection conn)
static

Definition at line 3685 of file mongoose.c.

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

Definition at line 3118 of file mongoose.c.

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

Definition at line 3070 of file mongoose.c.

static struct mg_connection* fc ( struct mg_context ctx)
static

Definition at line 551 of file mongoose.c.

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

Definition at line 2685 of file mongoose.c.

static void free_context ( struct mg_context ctx)
static

Definition at line 4039 of file mongoose.c.

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

Definition at line 1535 of file mongoose.c.

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

Definition at line 697 of file mongoose.c.

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

Definition at line 1761 of file mongoose.c.

static int get_option_index ( const char *  name)
static

Definition at line 474 of file mongoose.c.

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

Definition at line 1618 of file mongoose.c.

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

Definition at line 2887 of file mongoose.c.

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

Definition at line 2386 of file mongoose.c.

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

Definition at line 2503 of file mongoose.c.

static void handle_proxy_request ( struct mg_connection conn)
static

Definition at line 3726 of file mongoose.c.

static void handle_request ( struct mg_connection conn)
static

Definition at line 3219 of file mongoose.c.

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

Definition at line 3198 of file mongoose.c.

static int is_authorized_for_put ( struct mg_connection conn)
static

Definition at line 2218 of file mongoose.c.

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

Definition at line 2679 of file mongoose.c.

static int is_valid_http_method ( const char *  method)
static

Definition at line 2579 of file mongoose.c.

static int is_valid_uri ( const char *  uri)
static

Definition at line 3777 of file mongoose.c.

static int isbyte ( int  n)
static

Definition at line 3425 of file mongoose.c.

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

Definition at line 3528 of file mongoose.c.

static void log_access ( const struct mg_connection conn)
static

Definition at line 3389 of file mongoose.c.

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

Definition at line 3378 of file mongoose.c.

static int lowercase ( const char *  s)
static

Definition at line 568 of file mongoose.c.

static void master_thread ( struct mg_context ctx)
static

Definition at line 3979 of file mongoose.c.

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

Definition at line 754 of file mongoose.c.

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

Definition at line 1956 of file mongoose.c.

static void MD5Init ( MD5_CTX ctx)
static

Definition at line 1828 of file mongoose.c.

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

Definition at line 1838 of file mongoose.c.

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

Definition at line 1920 of file mongoose.c.

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

Definition at line 1578 of file mongoose.c.

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

Definition at line 1498 of file mongoose.c.

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

Definition at line 708 of file mongoose.c.

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

Definition at line 486 of file mongoose.c.

const char** mg_get_valid_option_names ( void  )

Definition at line 464 of file mongoose.c.

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

Definition at line 1462 of file mongoose.c.

void mg_md5 ( char *  buf,
  ... 
)

Definition at line 1998 of file mongoose.c.

int mg_modify_passwords_file ( struct mg_context ctx,
const char *  fname,
const char *  user,
const char *  pass 
)

Definition at line 2233 of file mongoose.c.

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

Definition at line 1415 of file mongoose.c.

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

Definition at line 1361 of file mongoose.c.

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

Definition at line 633 of file mongoose.c.

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

Definition at line 4076 of file mongoose.c.

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

Definition at line 1213 of file mongoose.c.

void mg_stop ( struct mg_context ctx)

Definition at line 4062 of file mongoose.c.

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

Definition at line 583 of file mongoose.c.

static char* mg_strdup ( const char *  str)
static

Definition at line 603 of file mongoose.c.

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

Definition at line 561 of file mongoose.c.

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

Definition at line 572 of file mongoose.c.

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

Definition at line 593 of file mongoose.c.

const char* mg_version ( void  )

Definition at line 557 of file mongoose.c.

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

Definition at line 611 of file mongoose.c.

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

Definition at line 1410 of file mongoose.c.

static int month_number_to_month_name ( const char *  s)
static

Definition at line 1639 of file mongoose.c.

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

Definition at line 718 of file mongoose.c.

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

Definition at line 2046 of file mongoose.c.

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

Definition at line 2081 of file mongoose.c.

static time_t parse_date_string ( const char *  s)
static

Definition at line 1650 of file mongoose.c.

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

Definition at line 2567 of file mongoose.c.

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

Definition at line 2586 of file mongoose.c.

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

Definition at line 3299 of file mongoose.c.

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

Definition at line 2499 of file mongoose.c.

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

Definition at line 3705 of file mongoose.c.

static void prepare_cgi_environment ( struct mg_connection conn,
const char *  prog,
struct cgi_env_block blk 
)
static

Definition at line 2789 of file mongoose.c.

static void print_dir_entry ( struct de de)
static

Definition at line 2325 of file mongoose.c.

static void process_new_connection ( struct mg_connection conn)
static

Definition at line 3783 of file mongoose.c.

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

Definition at line 3937 of file mongoose.c.

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

Definition at line 1342 of file mongoose.c.

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

Definition at line 1310 of file mongoose.c.

static int put_dir ( const char *  path)
static

Definition at line 3009 of file mongoose.c.

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

Definition at line 3035 of file mongoose.c.

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

Definition at line 2613 of file mongoose.c.

static void remove_double_dots_and_double_slashes ( char *  s)
static

Definition at line 1692 of file mongoose.c.

static void reset_per_request_attributes ( struct mg_connection conn)
static

Definition at line 3637 of file mongoose.c.

static void send_authorization_request ( struct mg_connection conn)
static

Definition at line 2208 of file mongoose.c.

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

Definition at line 2475 of file mongoose.c.

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

Definition at line 784 of file mongoose.c.

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

Definition at line 3133 of file mongoose.c.

static int set_acl_option ( struct mg_context ctx)
static

Definition at line 3632 of file mongoose.c.

static void set_close_on_exec ( int  fd)
static

Definition at line 1229 of file mongoose.c.

static int set_gpass_option ( struct mg_context ctx)
static

Definition at line 3626 of file mongoose.c.

static int set_non_blocking_mode ( SOCKET  sock)
static

Definition at line 1298 of file mongoose.c.

static int set_ports_option ( struct mg_context ctx)
static

Definition at line 3330 of file mongoose.c.

static int set_ssl_option ( struct mg_context ctx)
static

Definition at line 3561 of file mongoose.c.

static int set_uid_option ( struct mg_context ctx)
static

Definition at line 3485 of file mongoose.c.

static int should_keep_alive ( const struct mg_connection conn)
static

Definition at line 773 of file mongoose.c.

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

Definition at line 691 of file mongoose.c.

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

Definition at line 649 of file mongoose.c.

static pid_t spawn_process ( struct mg_connection conn,
const char *  prog,
char *  envblk,
char *  envp[],
int  fd_stdin,
int  fd_stdout,
const char *  dir 
)
static

Definition at line 1252 of file mongoose.c.

static const char* ssl_error ( void  )
static

Definition at line 543 of file mongoose.c.

static unsigned long ssl_id_callback ( void  )
static

Definition at line 3523 of file mongoose.c.

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

Definition at line 3511 of file mongoose.c.

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

Definition at line 1572 of file mongoose.c.

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

Definition at line 1233 of file mongoose.c.

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

Definition at line 2634 of file mongoose.c.

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

Definition at line 780 of file mongoose.c.

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

Definition at line 1432 of file mongoose.c.

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

Definition at line 2305 of file mongoose.c.

static void worker_thread ( struct mg_context ctx)
static

Definition at line 3869 of file mongoose.c.

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,
"T", "max_threads", NULL,
NULL
}

Definition at line 397 of file mongoose.c.

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}
}

Definition at line 337 of file mongoose.c.

size_t ext_len

Definition at line 1714 of file mongoose.c.

const char* extension

Definition at line 1713 of file mongoose.c.

const char* http_500_error = "Internal Server Error"
static

Definition at line 237 of file mongoose.c.

const char* mime_type

Definition at line 1715 of file mongoose.c.

size_t mime_type_len

Definition at line 1716 of file mongoose.c.

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

Definition at line 347 of file mongoose.c.

pthread_mutex_t* ssl_mutexes
static

Definition at line 3509 of file mongoose.c.

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}
}

Definition at line 315 of file mongoose.c.



jpeg_streamer
Author(s): Ken Tossell
autogenerated on Mon Jun 10 2019 12:51:47