Teonet library  0.4.7
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
mongoose.h File Reference
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <time.h>
#include <signal.h>
#include <assert.h>
#include <ctype.h>
#include <limits.h>
#include <stdarg.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <dirent.h>
#include <netdb.h>
#include <pthread.h>
#include <unistd.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include <sys/socket.h>
#include <sys/select.h>
#include <errno.h>
#include <inttypes.h>

Go to the source code of this file.

Data Structures

struct  mbuf
 
struct  cs_sha1_ctx
 
struct  MD5Context
 
struct  cs_base64_ctx
 
struct  json_token
 
union  socket_address
 
struct  mg_str
 
struct  mg_mgr
 
struct  mg_connection
 
struct  mg_add_sock_opts
 
struct  mg_bind_opts
 
struct  mg_connect_opts
 
struct  http_message
 
struct  websocket_message
 
struct  mg_serve_http_opts
 
struct  mg_rpc_request
 
struct  mg_rpc_reply
 
struct  mg_rpc_error
 
struct  mg_mqtt_message
 
struct  mg_mqtt_topic_expression
 
struct  mg_send_mqtt_handshake_opts
 
struct  mg_dns_resource_record
 
struct  mg_dns_message
 
struct  mg_resolve_async_opts
 

Macros

#define MG_VERSION   "6.0"
 
#define OSDEP_HEADER_INCLUDED
 
#define _MBCS   /* Use multibyte encoding on Windows */
 
#define _INTEGRAL_MAX_BITS   64 /* Enable _stati64() on Windows */
 
#define _CRT_SECURE_NO_WARNINGS   /* Disable deprecation warning in VS2005+ */
 
#define _XOPEN_SOURCE   600 /* For flockfile() on Linux */
 
#define __STDC_FORMAT_MACROS   /* <inttypes.h> wants this for C++ */
 
#define __STDC_LIMIT_MACROS   /* C++ wants that for INT64_MAX */
 
#define _LARGEFILE_SOURCE   /* Enable fseeko() and ftello() functions */
 
#define _FILE_OFFSET_BITS   64 /* Enable 64-bit file offsets */
 
#define LITTLE_ENDIAN   0x41424344
 
#define BIG_ENDIAN   0x44434241
 
#define PDP_ENDIAN   0x42414443
 
#define BYTE_ORDER   LITTLE_ENDIAN
 
#define va_copy(x, y)   (x) = (y)
 
#define closesocket(x)   close(x)
 
#define __cdecl
 
#define INVALID_SOCKET   (-1)
 
#define INT64_FMT   PRId64
 
#define SIZE_T_FMT   "zu"
 
#define to64(x)   strtoll(x, NULL, 10)
 
#define DIRSEP   '/'
 
#define ARRAY_SIZE(array)   (sizeof(array) / sizeof(array[0]))
 
#define _CS_DBG_H_
 
#define LOG(l, x)
 
#define DBG(x)
 
#define MBUF_H_INCLUDED
 
#define MBUF_SIZE_MULTIPLIER   1.5
 
#define MG_SHA1_HEADER_INCLUDED
 
#define MD5_HEADER_DEFINED
 
#define BASE64_H_INCLUDED
 
#define STR_UTIL_H
 
#define _MG_PROVIDE_STRNLEN
 
#define FROZEN_HEADER_INCLUDED
 
#define JSON_STRING_INVALID   -1
 
#define JSON_STRING_INCOMPLETE   -2
 
#define JSON_TOKEN_ARRAY_TOO_SMALL   -3
 
#define MG_NET_HEADER_INCLUDED
 
#define MG_RECV_FUNC(s, b, l, f)   recv(s, b, l, f)
 
#define MG_SEND_FUNC(s, b, l, f)   send(s, b, l, f)
 
#define MG_STR(str_literal)   { str_literal, sizeof(str_literal) - 1 }
 
#define MG_EV_POLL   0 /* Sent to each connection on each mg_mgr_poll() call */
 
#define MG_EV_ACCEPT   1 /* New connection accepted. union socket_address * */
 
#define MG_EV_CONNECT   2 /* connect() succeeded or failed. int * */
 
#define MG_EV_RECV   3 /* Data has benn received. int *num_bytes */
 
#define MG_EV_SEND   4 /* Data has been written to a socket. int *num_bytes */
 
#define MG_EV_CLOSE   5 /* Connection is closed. NULL */
 
#define MG_F_LISTENING   (1 << 0) /* This connection is listening */
 
#define MG_F_UDP   (1 << 1) /* This connection is UDP */
 
#define MG_F_RESOLVING   (1 << 2) /* Waiting for async resolver */
 
#define MG_F_CONNECTING   (1 << 3) /* connect() call in progress */
 
#define MG_F_SSL_HANDSHAKE_DONE   (1 << 4) /* SSL specific */
 
#define MG_F_WANT_READ   (1 << 5) /* SSL specific */
 
#define MG_F_WANT_WRITE   (1 << 6) /* SSL specific */
 
#define MG_F_IS_WEBSOCKET   (1 << 7) /* Websocket specific */
 
#define MG_F_SEND_AND_CLOSE   (1 << 10) /* Push remaining data and close */
 
#define MG_F_CLOSE_IMMEDIATELY   (1 << 11) /* Disconnect */
 
#define MG_F_WEBSOCKET_NO_DEFRAG   (1 << 12) /* Websocket specific */
 
#define MG_F_DELETE_CHUNK   (1 << 13) /* HTTP specific */
 
#define MG_F_USER_1   (1 << 20) /* Flags left for application */
 
#define MG_F_USER_2   (1 << 21)
 
#define MG_F_USER_3   (1 << 22)
 
#define MG_F_USER_4   (1 << 23)
 
#define MG_F_USER_5   (1 << 24)
 
#define MG_F_USER_6   (1 << 25)
 
#define MG_NET_IF_HEADER_INCLUDED
 
#define MG_UTIL_HEADER_DEFINED
 
#define MAX_PATH_SIZE   500
 
#define MG_SOCK_STRINGIFY_IP   1
 
#define MG_SOCK_STRINGIFY_PORT   2
 
#define MG_SOCK_STRINGIFY_REMOTE   4
 
#define MG_HTTP_HEADER_DEFINED
 
#define MG_MAX_HTTP_HEADERS   40
 
#define MG_MAX_HTTP_REQUEST_SIZE   8192
 
#define MG_MAX_PATH   1024
 
#define MG_MAX_HTTP_SEND_IOBUF   4096
 
#define MG_WEBSOCKET_PING_INTERVAL_SECONDS   5
 
#define MG_CGI_ENVIRONMENT_SIZE   8192
 
#define MG_MAX_CGI_ENVIR_VARS   64
 
#define MG_ENV_EXPORT_TO_CGI   "MONGOOSE_CGI"
 
#define MG_EV_HTTP_REQUEST   100 /* struct http_message * */
 
#define MG_EV_HTTP_REPLY   101 /* struct http_message * */
 
#define MG_EV_HTTP_CHUNK   102 /* struct http_message * */
 
#define MG_EV_SSI_CALL   105 /* char * */
 
#define MG_EV_WEBSOCKET_HANDSHAKE_REQUEST   111 /* NULL */
 
#define MG_EV_WEBSOCKET_HANDSHAKE_DONE   112 /* NULL */
 
#define MG_EV_WEBSOCKET_FRAME   113 /* struct websocket_message * */
 
#define MG_EV_WEBSOCKET_CONTROL_FRAME   114 /* struct websocket_message * */
 
#define WEBSOCKET_OP_CONTINUE   0
 
#define WEBSOCKET_OP_TEXT   1
 
#define WEBSOCKET_OP_BINARY   2
 
#define WEBSOCKET_OP_CLOSE   8
 
#define WEBSOCKET_OP_PING   9
 
#define WEBSOCKET_OP_PONG   10
 
#define WEBSOCKET_DONT_FIN   0x100
 
#define MG_JSON_RPC_HEADER_DEFINED
 
#define JSON_RPC_PARSE_ERROR   (-32700)
 
#define JSON_RPC_INVALID_REQUEST_ERROR   (-32600)
 
#define JSON_RPC_METHOD_NOT_FOUND_ERROR   (-32601)
 
#define JSON_RPC_INVALID_PARAMS_ERROR   (-32602)
 
#define JSON_RPC_INTERNAL_ERROR   (-32603)
 
#define JSON_RPC_SERVER_ERROR   (-32000)
 
#define MG_MQTT_HEADER_INCLUDED
 
#define MG_MQTT_CMD_CONNECT   1
 
#define MG_MQTT_CMD_CONNACK   2
 
#define MG_MQTT_CMD_PUBLISH   3
 
#define MG_MQTT_CMD_PUBACK   4
 
#define MG_MQTT_CMD_PUBREC   5
 
#define MG_MQTT_CMD_PUBREL   6
 
#define MG_MQTT_CMD_PUBCOMP   7
 
#define MG_MQTT_CMD_SUBSCRIBE   8
 
#define MG_MQTT_CMD_SUBACK   9
 
#define MG_MQTT_CMD_UNSUBSCRIBE   10
 
#define MG_MQTT_CMD_UNSUBACK   11
 
#define MG_MQTT_CMD_PINGREQ   12
 
#define MG_MQTT_CMD_PINGRESP   13
 
#define MG_MQTT_CMD_DISCONNECT   14
 
#define MG_MQTT_EVENT_BASE   200
 
#define MG_EV_MQTT_CONNECT   (MG_MQTT_EVENT_BASE + MG_MQTT_CMD_CONNECT)
 
#define MG_EV_MQTT_CONNACK   (MG_MQTT_EVENT_BASE + MG_MQTT_CMD_CONNACK)
 
#define MG_EV_MQTT_PUBLISH   (MG_MQTT_EVENT_BASE + MG_MQTT_CMD_PUBLISH)
 
#define MG_EV_MQTT_PUBACK   (MG_MQTT_EVENT_BASE + MG_MQTT_CMD_PUBACK)
 
#define MG_EV_MQTT_PUBREC   (MG_MQTT_EVENT_BASE + MG_MQTT_CMD_PUBREC)
 
#define MG_EV_MQTT_PUBREL   (MG_MQTT_EVENT_BASE + MG_MQTT_CMD_PUBREL)
 
#define MG_EV_MQTT_PUBCOMP   (MG_MQTT_EVENT_BASE + MG_MQTT_CMD_PUBCOMP)
 
#define MG_EV_MQTT_SUBSCRIBE   (MG_MQTT_EVENT_BASE + MG_MQTT_CMD_SUBSCRIBE)
 
#define MG_EV_MQTT_SUBACK   (MG_MQTT_EVENT_BASE + MG_MQTT_CMD_SUBACK)
 
#define MG_EV_MQTT_UNSUBSCRIBE   (MG_MQTT_EVENT_BASE + MG_MQTT_CMD_UNSUBSCRIBE)
 
#define MG_EV_MQTT_UNSUBACK   (MG_MQTT_EVENT_BASE + MG_MQTT_CMD_UNSUBACK)
 
#define MG_EV_MQTT_PINGREQ   (MG_MQTT_EVENT_BASE + MG_MQTT_CMD_PINGREQ)
 
#define MG_EV_MQTT_PINGRESP   (MG_MQTT_EVENT_BASE + MG_MQTT_CMD_PINGRESP)
 
#define MG_EV_MQTT_DISCONNECT   (MG_MQTT_EVENT_BASE + MG_MQTT_CMD_DISCONNECT)
 
#define MG_MQTT_RETAIN   0x1
 
#define MG_MQTT_DUP   0x4
 
#define MG_MQTT_QOS(qos)   ((qos) << 1)
 
#define MG_MQTT_GET_QOS(flags)   (((flags) &0x6) >> 1)
 
#define MG_MQTT_SET_QOS(flags, qos)   (flags) = ((flags) & ~0x6) | ((qos) << 1)
 
#define MG_MQTT_CLEAN_SESSION   0x02
 
#define MG_MQTT_HAS_WILL   0x04
 
#define MG_MQTT_WILL_RETAIN   0x20
 
#define MG_MQTT_HAS_PASSWORD   0x40
 
#define MG_MQTT_HAS_USER_NAME   0x80
 
#define MG_MQTT_GET_WILL_QOS(flags)   (((flags) &0x18) >> 3)
 
#define MG_MQTT_SET_WILL_QOS(flags, qos)   (flags) = ((flags) & ~0x18) | ((qos) << 3)
 
#define MG_EV_MQTT_CONNACK_ACCEPTED   0
 
#define MG_EV_MQTT_CONNACK_UNACCEPTABLE_VERSION   1
 
#define MG_EV_MQTT_CONNACK_IDENTIFIER_REJECTED   2
 
#define MG_EV_MQTT_CONNACK_SERVER_UNAVAILABLE   3
 
#define MG_EV_MQTT_CONNACK_BAD_AUTH   4
 
#define MG_EV_MQTT_CONNACK_NOT_AUTHORIZED   5
 
#define MG_MQTT_BROKER_HEADER_INCLUDED
 
#define MG_DNS_HEADER_DEFINED
 
#define MG_DNS_A_RECORD   0x01 /* Lookup IP address */
 
#define MG_DNS_CNAME_RECORD   0x05 /* Lookup CNAME */
 
#define MG_DNS_AAAA_RECORD   0x1c /* Lookup IPv6 address */
 
#define MG_DNS_MX_RECORD   0x0f /* Lookup mail server for domain */
 
#define MG_MAX_DNS_QUESTIONS   32
 
#define MG_MAX_DNS_ANSWERS   32
 
#define MG_DNS_MESSAGE   100 /* High-level DNS message event */
 
#define MG_DNS_SERVER_HEADER_DEFINED
 
#define MG_RESOLV_HEADER_DEFINED
 
#define MG_COAP_HEADER_INCLUDED
 

Typedefs

typedef int sock_t
 
typedef struct stat cs_stat_t
 
typedef struct MD5Context MD5_CTX
 
typedef void(* cs_base64_putc_t )(char, void *)
 
typedef void * SSL
 
typedef void * SSL_CTX
 
typedef void(* mg_event_handler_t )(struct mg_connection *, int ev, void *)
 
typedef int(* mg_rpc_handler_t )(char *buf, int len, struct mg_rpc_request *)
 
typedef void(* mg_resolve_callback_t )(struct mg_dns_message *, void *)
 

Enumerations

enum  cs_log_level {
  LL_NONE = -1, LL_ERROR = 0, LL_WARN = 1, LL_INFO = 2,
  LL_DEBUG = 3, _LL_MIN = -2, _LL_MAX = 4
}
 
enum  json_type {
  JSON_TYPE_EOF = 0, JSON_TYPE_STRING = 1, JSON_TYPE_NUMBER = 2, JSON_TYPE_OBJECT = 3,
  JSON_TYPE_TRUE = 4, JSON_TYPE_FALSE = 5, JSON_TYPE_NULL = 6, JSON_TYPE_ARRAY = 7
}
 
enum  mg_dns_resource_record_kind { MG_DNS_INVALID_RECORD = 0, MG_DNS_QUESTION, MG_DNS_ANSWER }
 

Functions

void cs_log_set_level (enum cs_log_level level)
 
void cs_log_printf (const char *fmt,...)
 
void mbuf_init (struct mbuf *, size_t initial_capacity)
 
void mbuf_free (struct mbuf *)
 
size_t mbuf_append (struct mbuf *, const void *data, size_t data_size)
 
size_t mbuf_insert (struct mbuf *, size_t, const void *, size_t)
 
void mbuf_remove (struct mbuf *, size_t data_size)
 
void mbuf_resize (struct mbuf *, size_t new_size)
 
void mbuf_trim (struct mbuf *)
 
void cs_sha1_init (cs_sha1_ctx *)
 
void cs_sha1_update (cs_sha1_ctx *, const unsigned char *data, uint32_t len)
 
void cs_sha1_final (unsigned char digest[20], cs_sha1_ctx *)
 
void cs_hmac_sha1 (const unsigned char *key, size_t key_len, const unsigned char *text, size_t text_len, unsigned char out[20])
 
void MD5_Init (MD5_CTX *c)
 
void MD5_Update (MD5_CTX *c, const unsigned char *data, size_t len)
 
void MD5_Final (unsigned char *md, MD5_CTX *c)
 
char * cs_md5 (char buf[33],...)
 
void cs_to_hex (char *to, const unsigned char *p, size_t len)
 
void cs_base64_init (struct cs_base64_ctx *ctx, cs_base64_putc_t putc, void *user_data)
 
void cs_base64_update (struct cs_base64_ctx *ctx, const char *str, size_t len)
 
void cs_base64_finish (struct cs_base64_ctx *ctx)
 
void cs_base64_encode (const unsigned char *src, int src_len, char *dst)
 
void cs_fprint_base64 (FILE *f, const unsigned char *src, int src_len)
 
int cs_base64_decode (const unsigned char *s, int len, char *dst)
 
int c_snprintf (char *buf, size_t buf_size, const char *format,...)
 
int c_vsnprintf (char *buf, size_t buf_size, const char *format, va_list ap)
 
size_t strnlen (const char *s, size_t maxlen)
 
int parse_json (const char *json_string, int json_string_length, struct json_token *tokens_array, int size_of_tokens_array)
 
struct json_tokenparse_json2 (const char *json_string, int string_length)
 
struct json_tokenfind_json_token (struct json_token *toks, const char *path)
 
int json_emit_long (char *buf, int buf_len, long value)
 
int json_emit_double (char *buf, int buf_len, double value)
 
int json_emit_quoted_str (char *buf, int buf_len, const char *str, int len)
 
int json_emit_unquoted_str (char *buf, int buf_len, const char *str, int len)
 
int json_emit (char *buf, int buf_len, const char *fmt,...)
 
int json_emit_va (char *buf, int buf_len, const char *fmt, va_list)
 
void mg_mgr_init (struct mg_mgr *mgr, void *user_data)
 
void mg_mgr_free (struct mg_mgr *)
 
time_t mg_mgr_poll (struct mg_mgr *, int milli)
 
void mg_broadcast (struct mg_mgr *, mg_event_handler_t func, void *, size_t)
 
struct mg_connectionmg_next (struct mg_mgr *, struct mg_connection *)
 
struct mg_connectionmg_add_sock (struct mg_mgr *, sock_t, mg_event_handler_t)
 
struct mg_connectionmg_add_sock_opt (struct mg_mgr *, sock_t, mg_event_handler_t, struct mg_add_sock_opts)
 
struct mg_connectionmg_bind (struct mg_mgr *, const char *, mg_event_handler_t)
 
struct mg_connectionmg_bind_opt (struct mg_mgr *, const char *, mg_event_handler_t, struct mg_bind_opts)
 
struct mg_connectionmg_connect (struct mg_mgr *, const char *, mg_event_handler_t)
 
struct mg_connectionmg_connect_opt (struct mg_mgr *, const char *, mg_event_handler_t, struct mg_connect_opts)
 
const char * mg_set_ssl (struct mg_connection *nc, const char *cert, const char *ca_cert)
 
void mg_send (struct mg_connection *, const void *buf, int len)
 
int mg_printf (struct mg_connection *, const char *fmt,...)
 
int mg_vprintf (struct mg_connection *, const char *fmt, va_list ap)
 
int mg_socketpair (sock_t[2], int sock_type)
 
int mg_resolve (const char *domain_name, char *ip_addr_buf, size_t buf_len)
 
int mg_check_ip_acl (const char *acl, uint32_t remote_ip)
 
void mg_enable_multithreading (struct mg_connection *nc)
 
void mg_if_connect_tcp (struct mg_connection *nc, const union socket_address *sa)
 
void mg_if_connect_udp (struct mg_connection *nc)
 
void mg_if_connect_cb (struct mg_connection *nc, int err)
 
int mg_if_listen_tcp (struct mg_connection *nc, union socket_address *sa)
 
struct mg_connectionmg_if_accept_tcp_cb (struct mg_connection *lc, union socket_address *sa, size_t sa_len)
 
int mg_if_listen_udp (struct mg_connection *nc, union socket_address *sa)
 
void mg_if_tcp_send (struct mg_connection *nc, const void *buf, size_t len)
 
void mg_if_udp_send (struct mg_connection *nc, const void *buf, size_t len)
 
void mg_if_sent_cb (struct mg_connection *nc, int num_sent)
 
void mg_if_recv_tcp_cb (struct mg_connection *nc, void *buf, int len)
 
void mg_if_recv_udp_cb (struct mg_connection *nc, void *buf, int len, union socket_address *sa, size_t sa_len)
 
void mg_if_recved (struct mg_connection *nc, size_t len)
 
void mg_if_poll (struct mg_connection *nc, time_t now)
 
void mg_if_destroy_conn (struct mg_connection *nc)
 
void mg_close_conn (struct mg_connection *nc)
 
const char * mg_skip (const char *s, const char *end_string, const char *delimiters, struct mg_str *v)
 
int mg_ncasecmp (const char *s1, const char *s2, size_t len)
 
int mg_casecmp (const char *s1, const char *s2)
 
int mg_vcmp (const struct mg_str *str2, const char *str1)
 
int mg_vcasecmp (const struct mg_str *str2, const char *str1)
 
int mg_base64_decode (const unsigned char *s, int len, char *dst)
 
void mg_base64_encode (const unsigned char *src, int src_len, char *dst)
 
int mg_stat (const char *path, cs_stat_t *st)
 
FILE * mg_fopen (const char *path, const char *mode)
 
int mg_open (const char *path, int flag, int mode)
 
void mg_set_close_on_exec (sock_t)
 
void mg_sock_to_str (sock_t sock, char *buf, size_t len, int flags)
 
void mg_sock_addr_to_str (const union socket_address *sa, char *buf, size_t len, int flags)
 
int mg_hexdump (const void *buf, int len, char *dst, int dst_len)
 
void mg_hexdump_connection (struct mg_connection *nc, const char *path, int num_bytes, int ev)
 
int mg_avprintf (char **buf, size_t size, const char *fmt, va_list ap)
 
int mg_is_big_endian (void)
 
const char * mg_next_comma_list_entry (const char *list, struct mg_str *val, struct mg_str *eq_val)
 
int mg_match_prefix (const char *pattern, int pattern_len, const char *str)
 
void mg_set_protocol_http_websocket (struct mg_connection *nc)
 
void mg_send_websocket_handshake (struct mg_connection *nc, const char *uri, const char *extra_headers)
 
void mg_send_websocket_frame (struct mg_connection *nc, int op_and_flags, const void *data, size_t data_len)
 
void mg_send_websocket_framev (struct mg_connection *nc, int op_and_flags, const struct mg_str *strings, int num_strings)
 
void mg_printf_websocket_frame (struct mg_connection *nc, int op_and_flags, const char *fmt,...)
 
void mg_send_http_chunk (struct mg_connection *nc, const char *buf, size_t len)
 
void mg_printf_http_chunk (struct mg_connection *, const char *,...)
 
void mg_send_response_line (struct mg_connection *c, int status_code, const char *extra_headers)
 
void mg_send_head (struct mg_connection *n, int status_code, int64_t content_length, const char *extra_headers)
 
void mg_printf_html_escape (struct mg_connection *, const char *,...)
 
int mg_parse_http (const char *s, int n, struct http_message *hm, int is_req)
 
struct mg_strmg_get_http_header (struct http_message *hm, const char *name)
 
int mg_http_parse_header (struct mg_str *hdr, const char *var_name, char *buf, size_t buf_size)
 
size_t mg_parse_multipart (const char *buf, size_t buf_len, char *var_name, size_t var_name_len, char *file_name, size_t file_name_len, const char **chunk, size_t *chunk_len)
 
int mg_get_http_var (const struct mg_str *, const char *, char *dst, size_t)
 
int mg_http_create_digest_auth_header (char *buf, size_t buf_len, const char *method, const char *uri, const char *auth_domain, const char *user, const char *passwd)
 
struct mg_connectionmg_connect_http (struct mg_mgr *, mg_event_handler_t event_handler, const char *url, const char *extra_headers, const char *post_data)
 
void mg_serve_http (struct mg_connection *, struct http_message *, struct mg_serve_http_opts)
 
int mg_rpc_parse_reply (const char *buf, int len, struct json_token *toks, int max_toks, struct mg_rpc_reply *, struct mg_rpc_error *)
 
int mg_rpc_create_request (char *buf, int len, const char *method, const char *id, const char *params_fmt,...)
 
int mg_rpc_create_reply (char *buf, int len, const struct mg_rpc_request *req, const char *result_fmt,...)
 
int mg_rpc_create_error (char *buf, int len, struct mg_rpc_request *req, int code, const char *message, const char *fmt,...)
 
int mg_rpc_create_std_error (char *, int, struct mg_rpc_request *, int code)
 
int mg_rpc_dispatch (const char *buf, int, char *dst, int dst_len, const char **methods, mg_rpc_handler_t *handlers)
 
void mg_set_protocol_mqtt (struct mg_connection *)
 
void mg_send_mqtt_handshake (struct mg_connection *nc, const char *client_id)
 
void mg_send_mqtt_handshake_opt (struct mg_connection *, const char *client_id, struct mg_send_mqtt_handshake_opts)
 
void mg_mqtt_publish (struct mg_connection *nc, const char *topic, uint16_t message_id, int flags, const void *data, size_t len)
 
void mg_mqtt_subscribe (struct mg_connection *nc, const struct mg_mqtt_topic_expression *topics, size_t topics_len, uint16_t message_id)
 
void mg_mqtt_unsubscribe (struct mg_connection *nc, char **topics, size_t topics_len, uint16_t message_id)
 
void mg_mqtt_disconnect (struct mg_connection *nc)
 
void mg_mqtt_connack (struct mg_connection *, uint8_t)
 
void mg_mqtt_puback (struct mg_connection *, uint16_t)
 
void mg_mqtt_pubrec (struct mg_connection *, uint16_t)
 
void mg_mqtt_pubrel (struct mg_connection *, uint16_t)
 
void mg_mqtt_pubcomp (struct mg_connection *, uint16_t)
 
void mg_mqtt_suback (struct mg_connection *, uint8_t *, size_t, uint16_t)
 
void mg_mqtt_unsuback (struct mg_connection *, uint16_t)
 
void mg_mqtt_ping (struct mg_connection *)
 
void mg_mqtt_pong (struct mg_connection *)
 
int mg_mqtt_next_subscribe_topic (struct mg_mqtt_message *, struct mg_str *, uint8_t *, int)
 
struct mg_dns_resource_recordmg_dns_next_record (struct mg_dns_message *, int, struct mg_dns_resource_record *)
 
int mg_dns_parse_record_data (struct mg_dns_message *, struct mg_dns_resource_record *, void *, size_t)
 
void mg_send_dns_query (struct mg_connection *, const char *, int)
 
int mg_dns_insert_header (struct mbuf *, size_t, struct mg_dns_message *)
 
int mg_dns_copy_body (struct mbuf *, struct mg_dns_message *)
 
int mg_dns_encode_record (struct mbuf *, struct mg_dns_resource_record *, const char *, size_t, const void *, size_t)
 
int mg_parse_dns (const char *, int, struct mg_dns_message *)
 
size_t mg_dns_uncompress_name (struct mg_dns_message *, struct mg_str *, char *, int)
 
void mg_set_protocol_dns (struct mg_connection *)
 
int mg_resolve_async (struct mg_mgr *, const char *, int, mg_resolve_callback_t, void *data)
 
int mg_resolve_async_opt (struct mg_mgr *, const char *, int, mg_resolve_callback_t, void *data, struct mg_resolve_async_opts opts)
 
int mg_resolve_from_hosts_file (const char *host, union socket_address *usa)
 

Variables

enum cs_log_level s_cs_log_level
 

Macro Definition Documentation

#define __cdecl
#define __STDC_FORMAT_MACROS   /* <inttypes.h> wants this for C++ */
#define __STDC_LIMIT_MACROS   /* C++ wants that for INT64_MAX */
#define _CRT_SECURE_NO_WARNINGS   /* Disable deprecation warning in VS2005+ */
#define _CS_DBG_H_
#define _FILE_OFFSET_BITS   64 /* Enable 64-bit file offsets */
#define _INTEGRAL_MAX_BITS   64 /* Enable _stati64() on Windows */
#define _LARGEFILE_SOURCE   /* Enable fseeko() and ftello() functions */
#define _MBCS   /* Use multibyte encoding on Windows */
#define _MG_PROVIDE_STRNLEN
#define _XOPEN_SOURCE   600 /* For flockfile() on Linux */
#define ARRAY_SIZE (   array)    (sizeof(array) / sizeof(array[0]))
#define BASE64_H_INCLUDED
#define BIG_ENDIAN   0x44434241
#define BYTE_ORDER   LITTLE_ENDIAN
#define closesocket (   x)    close(x)
#define DBG (   x)
Value:
fprintf(stderr, "%-20s ", __func__); \
}
Definition: mongoose.h:283
enum cs_log_level s_cs_log_level
Definition: mongoose.c:325
void cs_log_printf(const char *fmt,...)
Definition: mongoose.c:332

Referenced by http_handler(), mg_add_conn(), mg_bind_opt(), mg_call(), mg_close_conn(), mg_connect_http(), mg_do_connect(), mg_ev_mgr_init(), mg_if_accept_tcp_cb(), mg_if_connect_cb(), mg_if_connect_tcp(), mg_if_recv_udp_cb(), mg_if_udp_send(), mg_is_error(), mg_mgr_free(), mg_mgr_handle_conn(), mg_mgr_init(), mg_mgr_poll(), mg_resolve_async_opt(), mg_send_dns_query(), mg_send_http_file(), and mg_stat().

#define DIRSEP   '/'
#define FROZEN_HEADER_INCLUDED
#define INT64_FMT   PRId64

Referenced by mg_send_head().

#define JSON_RPC_INTERNAL_ERROR   (-32603)
#define JSON_RPC_INVALID_PARAMS_ERROR   (-32602)

Referenced by mg_rpc_create_std_error().

#define JSON_RPC_INVALID_REQUEST_ERROR   (-32600)
#define JSON_RPC_METHOD_NOT_FOUND_ERROR   (-32601)
#define JSON_RPC_PARSE_ERROR   (-32700)
#define JSON_RPC_SERVER_ERROR   (-32000)
#define JSON_STRING_INCOMPLETE   -2
#define JSON_STRING_INVALID   -1

Referenced by mg_rpc_dispatch().

#define JSON_TOKEN_ARRAY_TOO_SMALL   -3
#define LITTLE_ENDIAN   0x41424344
#define LOG (   l,
 
)
Value:
if (s_cs_log_level >= l) { \
fprintf(stderr, "%-20s ", __func__); \
}
enum cs_log_level s_cs_log_level
Definition: mongoose.c:325
void cs_log_printf(const char *fmt,...)
Definition: mongoose.c:332
#define MAX_PATH_SIZE   500

Referenced by mg_fopen(), mg_open(), and mg_stat().

#define MBUF_H_INCLUDED
#define MBUF_SIZE_MULTIPLIER   1.5

Referenced by mbuf_insert().

#define MD5_HEADER_DEFINED
#define MG_CGI_ENVIRONMENT_SIZE   8192
#define MG_COAP_HEADER_INCLUDED
#define MG_DNS_A_RECORD   0x01 /* Lookup IP address */
#define MG_DNS_AAAA_RECORD   0x1c /* Lookup IPv6 address */
#define MG_DNS_CNAME_RECORD   0x05 /* Lookup CNAME */
#define MG_DNS_HEADER_DEFINED
#define MG_DNS_MESSAGE   100 /* High-level DNS message event */
#define MG_DNS_MX_RECORD   0x0f /* Lookup mail server for domain */
#define MG_DNS_SERVER_HEADER_DEFINED
#define MG_ENV_EXPORT_TO_CGI   "MONGOOSE_CGI"
#define MG_EV_ACCEPT   1 /* New connection accepted. union socket_address * */
#define MG_EV_CLOSE   5 /* Connection is closed. NULL */

Referenced by http_handler(), and mg_close_conn().

#define MG_EV_CONNECT   2 /* connect() succeeded or failed. int * */
#define MG_EV_HTTP_CHUNK   102 /* struct http_message * */

Referenced by mg_handle_chunked().

#define MG_EV_HTTP_REPLY   101 /* struct http_message * */

Referenced by http_handler().

#define MG_EV_HTTP_REQUEST   100 /* struct http_message * */

Referenced by http_handler().

#define MG_EV_MQTT_CONNACK   (MG_MQTT_EVENT_BASE + MG_MQTT_CMD_CONNACK)
#define MG_EV_MQTT_CONNACK_ACCEPTED   0
#define MG_EV_MQTT_CONNACK_BAD_AUTH   4
#define MG_EV_MQTT_CONNACK_IDENTIFIER_REJECTED   2
#define MG_EV_MQTT_CONNACK_NOT_AUTHORIZED   5
#define MG_EV_MQTT_CONNACK_SERVER_UNAVAILABLE   3
#define MG_EV_MQTT_CONNACK_UNACCEPTABLE_VERSION   1
#define MG_EV_MQTT_CONNECT   (MG_MQTT_EVENT_BASE + MG_MQTT_CMD_CONNECT)
#define MG_EV_MQTT_DISCONNECT   (MG_MQTT_EVENT_BASE + MG_MQTT_CMD_DISCONNECT)
#define MG_EV_MQTT_PINGREQ   (MG_MQTT_EVENT_BASE + MG_MQTT_CMD_PINGREQ)
#define MG_EV_MQTT_PINGRESP   (MG_MQTT_EVENT_BASE + MG_MQTT_CMD_PINGRESP)
#define MG_EV_MQTT_PUBACK   (MG_MQTT_EVENT_BASE + MG_MQTT_CMD_PUBACK)
#define MG_EV_MQTT_PUBCOMP   (MG_MQTT_EVENT_BASE + MG_MQTT_CMD_PUBCOMP)
#define MG_EV_MQTT_PUBLISH   (MG_MQTT_EVENT_BASE + MG_MQTT_CMD_PUBLISH)
#define MG_EV_MQTT_PUBREC   (MG_MQTT_EVENT_BASE + MG_MQTT_CMD_PUBREC)
#define MG_EV_MQTT_PUBREL   (MG_MQTT_EVENT_BASE + MG_MQTT_CMD_PUBREL)
#define MG_EV_MQTT_SUBACK   (MG_MQTT_EVENT_BASE + MG_MQTT_CMD_SUBACK)
#define MG_EV_MQTT_SUBSCRIBE   (MG_MQTT_EVENT_BASE + MG_MQTT_CMD_SUBSCRIBE)
#define MG_EV_MQTT_UNSUBACK   (MG_MQTT_EVENT_BASE + MG_MQTT_CMD_UNSUBACK)
#define MG_EV_MQTT_UNSUBSCRIBE   (MG_MQTT_EVENT_BASE + MG_MQTT_CMD_UNSUBSCRIBE)
#define MG_EV_POLL   0 /* Sent to each connection on each mg_mgr_poll() call */

Referenced by mg_call(), and mg_if_poll().

#define MG_EV_RECV   3 /* Data has benn received. int *num_bytes */
#define MG_EV_SEND   4 /* Data has been written to a socket. int *num_bytes */
#define MG_EV_SSI_CALL   105 /* char * */
#define MG_EV_WEBSOCKET_CONTROL_FRAME   114 /* struct websocket_message * */
#define MG_EV_WEBSOCKET_FRAME   113 /* struct websocket_message * */
#define MG_EV_WEBSOCKET_HANDSHAKE_DONE   112 /* NULL */

Referenced by http_handler().

#define MG_EV_WEBSOCKET_HANDSHAKE_REQUEST   111 /* NULL */

Referenced by http_handler().

#define MG_F_CLOSE_IMMEDIATELY   (1 << 11) /* Disconnect */
#define MG_F_CONNECTING   (1 << 3) /* connect() call in progress */
#define MG_F_DELETE_CHUNK   (1 << 13) /* HTTP specific */

Referenced by mg_handle_chunked().

#define MG_F_IS_WEBSOCKET   (1 << 7) /* Websocket specific */

Referenced by http_handler().

#define MG_F_LISTENING   (1 << 0) /* This connection is listening */
#define MG_F_RESOLVING   (1 << 2) /* Waiting for async resolver */
#define MG_F_SEND_AND_CLOSE   (1 << 10) /* Push remaining data and close */
#define MG_F_SSL_HANDSHAKE_DONE   (1 << 4) /* SSL specific */
#define MG_F_UDP   (1 << 1) /* This connection is UDP */
#define MG_F_USER_1   (1 << 20) /* Flags left for application */
#define MG_F_USER_2   (1 << 21)
#define MG_F_USER_3   (1 << 22)
#define MG_F_USER_4   (1 << 23)
#define MG_F_USER_5   (1 << 24)
#define MG_F_USER_6   (1 << 25)
#define MG_F_WANT_READ   (1 << 5) /* SSL specific */

Referenced by mg_mgr_poll().

#define MG_F_WANT_WRITE   (1 << 6) /* SSL specific */

Referenced by mg_mgr_poll().

#define MG_F_WEBSOCKET_NO_DEFRAG   (1 << 12) /* Websocket specific */
#define MG_HTTP_HEADER_DEFINED
#define MG_JSON_RPC_HEADER_DEFINED
#define MG_MAX_CGI_ENVIR_VARS   64
#define MG_MAX_DNS_ANSWERS   32
#define MG_MAX_DNS_QUESTIONS   32
#define MG_MAX_HTTP_HEADERS   40
#define MG_MAX_HTTP_REQUEST_SIZE   8192

Referenced by http_handler().

#define MG_MAX_HTTP_SEND_IOBUF   4096
#define MG_MAX_PATH   1024

Referenced by mg_serve_http().

#define MG_MQTT_BROKER_HEADER_INCLUDED
#define MG_MQTT_CLEAN_SESSION   0x02
#define MG_MQTT_CMD_CONNACK   2

Referenced by mg_mqtt_connack().

#define MG_MQTT_CMD_CONNECT   1
#define MG_MQTT_CMD_DISCONNECT   14

Referenced by mg_mqtt_disconnect().

#define MG_MQTT_CMD_PINGREQ   12

Referenced by mg_mqtt_ping().

#define MG_MQTT_CMD_PINGRESP   13

Referenced by mg_mqtt_pong().

#define MG_MQTT_CMD_PUBACK   4

Referenced by mg_mqtt_puback().

#define MG_MQTT_CMD_PUBCOMP   7

Referenced by mg_mqtt_pubcomp().

#define MG_MQTT_CMD_PUBLISH   3

Referenced by mg_mqtt_publish().

#define MG_MQTT_CMD_PUBREC   5

Referenced by mg_mqtt_pubrec().

#define MG_MQTT_CMD_PUBREL   6

Referenced by mg_mqtt_pubrel().

#define MG_MQTT_CMD_SUBACK   9

Referenced by mg_mqtt_suback().

#define MG_MQTT_CMD_SUBSCRIBE   8

Referenced by mg_mqtt_subscribe().

#define MG_MQTT_CMD_UNSUBACK   11

Referenced by mg_mqtt_unsuback().

#define MG_MQTT_CMD_UNSUBSCRIBE   10

Referenced by mg_mqtt_unsubscribe().

#define MG_MQTT_DUP   0x4
#define MG_MQTT_EVENT_BASE   200
#define MG_MQTT_GET_QOS (   flags)    (((flags) &0x6) >> 1)

Referenced by mg_mqtt_publish().

#define MG_MQTT_GET_WILL_QOS (   flags)    (((flags) &0x18) >> 3)
#define MG_MQTT_HAS_PASSWORD   0x40
#define MG_MQTT_HAS_USER_NAME   0x80
#define MG_MQTT_HAS_WILL   0x04
#define MG_MQTT_HEADER_INCLUDED
#define MG_MQTT_QOS (   qos)    ((qos) << 1)
#define MG_MQTT_RETAIN   0x1
#define MG_MQTT_SET_QOS (   flags,
  qos 
)    (flags) = ((flags) & ~0x6) | ((qos) << 1)
#define MG_MQTT_SET_WILL_QOS (   flags,
  qos 
)    (flags) = ((flags) & ~0x18) | ((qos) << 3)
#define MG_MQTT_WILL_RETAIN   0x20
#define MG_NET_HEADER_INCLUDED
#define MG_NET_IF_HEADER_INCLUDED
#define MG_RECV_FUNC (   s,
  b,
  l,
 
)    recv(s, b, l, f)

Referenced by mg_broadcast().

#define MG_RESOLV_HEADER_DEFINED
#define MG_SEND_FUNC (   s,
  b,
  l,
 
)    send(s, b, l, f)

Referenced by mg_broadcast().

#define MG_SHA1_HEADER_INCLUDED
#define MG_SOCK_STRINGIFY_IP   1

Referenced by mg_sock_addr_to_str().

#define MG_SOCK_STRINGIFY_PORT   2

Referenced by mg_sock_addr_to_str().

#define MG_SOCK_STRINGIFY_REMOTE   4

Referenced by mg_sock_to_str().

#define MG_STR (   str_literal)    { str_literal, sizeof(str_literal) - 1 }
#define MG_UTIL_HEADER_DEFINED
#define MG_VERSION   "6.0"
#define MG_WEBSOCKET_PING_INTERVAL_SECONDS   5
#define OSDEP_HEADER_INCLUDED
#define PDP_ENDIAN   0x42414443
#define SIZE_T_FMT   "zu"

Referenced by mg_connect_http().

#define STR_UTIL_H
#define to64 (   x)    strtoll(x, NULL, 10)
#define va_copy (   x,
 
)    (x) = (y)
#define WEBSOCKET_DONT_FIN   0x100
#define WEBSOCKET_OP_BINARY   2
#define WEBSOCKET_OP_CLOSE   8
#define WEBSOCKET_OP_CONTINUE   0
#define WEBSOCKET_OP_PING   9
#define WEBSOCKET_OP_PONG   10
#define WEBSOCKET_OP_TEXT   1

Referenced by event_cb().

Typedef Documentation

typedef void(* cs_base64_putc_t)(char, void *)
typedef struct stat cs_stat_t
typedef struct MD5Context MD5_CTX
typedef void(* mg_event_handler_t)(struct mg_connection *, int ev, void *)
typedef void(* mg_resolve_callback_t)(struct mg_dns_message *, void *)
typedef int(* mg_rpc_handler_t)(char *buf, int len, struct mg_rpc_request *)
typedef int sock_t
typedef void* SSL
typedef void* SSL_CTX

Enumeration Type Documentation

Enumerator
LL_NONE 
LL_ERROR 
LL_WARN 
LL_INFO 
LL_DEBUG 
_LL_MIN 
_LL_MAX 
enum json_type
Enumerator
JSON_TYPE_EOF 
JSON_TYPE_STRING 
JSON_TYPE_NUMBER 
JSON_TYPE_OBJECT 
JSON_TYPE_TRUE 
JSON_TYPE_FALSE 
JSON_TYPE_NULL 
JSON_TYPE_ARRAY 
Enumerator
MG_DNS_INVALID_RECORD 
MG_DNS_QUESTION 
MG_DNS_ANSWER 

Function Documentation

int c_snprintf ( char *  buf,
size_t  buf_size,
const char *  format,
  ... 
)

References c_vsnprintf(), and result.

int c_vsnprintf ( char *  buf,
size_t  buf_size,
const char *  format,
va_list  ap 
)
int cs_base64_decode ( const unsigned char *  s,
int  len,
char *  dst 
)

Referenced by mg_base64_decode().

void cs_base64_encode ( const unsigned char *  src,
int  src_len,
char *  dst 
)

References BASE64_ENCODE_BODY.

Referenced by mg_base64_encode().

void cs_base64_init ( struct cs_base64_ctx ctx,
cs_base64_putc_t  putc,
void *  user_data 
)
void cs_base64_update ( struct cs_base64_ctx ctx,
const char *  str,
size_t  len 
)
void cs_fprint_base64 ( FILE *  f,
const unsigned char *  src,
int  src_len 
)

References BASE64_ENCODE_BODY.

void cs_hmac_sha1 ( const unsigned char *  key,
size_t  key_len,
const unsigned char *  text,
size_t  text_len,
unsigned char  out[20] 
)
void cs_log_printf ( const char *  fmt,
  ... 
)
void cs_log_set_level ( enum cs_log_level  level)
char* cs_md5 ( char  buf[33],
  ... 
)
void cs_sha1_final ( unsigned char  digest[20],
cs_sha1_ctx  
)
void cs_sha1_init ( cs_sha1_ctx )

References cs_sha1_ctx::count, and cs_sha1_ctx::state.

Referenced by cs_hmac_sha1().

void cs_sha1_update ( cs_sha1_ctx ,
const unsigned char *  data,
uint32_t  len 
)
void cs_to_hex ( char *  to,
const unsigned char *  p,
size_t  len 
)

Referenced by cs_md5().

struct json_token* find_json_token ( struct json_token toks,
const char *  path 
)
int json_emit ( char *  buf,
int  buf_len,
const char *  fmt,
  ... 
)
int json_emit_double ( char *  buf,
int  buf_len,
double  value 
)

Referenced by json_emit_va().

int json_emit_long ( char *  buf,
int  buf_len,
long  value 
)
int json_emit_quoted_str ( char *  buf,
int  buf_len,
const char *  str,
int  len 
)

References EMIT, and json_token::len.

Referenced by json_emit_va(), and mg_rpc_create_reply().

int json_emit_unquoted_str ( char *  buf,
int  buf_len,
const char *  str,
int  len 
)

References json_token::len.

Referenced by json_emit_va(), and mg_rpc_create_reply().

int json_emit_va ( char *  buf,
int  buf_len,
const char *  fmt,
va_list   
)
size_t mbuf_append ( struct mbuf ,
const void *  data,
size_t  data_size 
)
void mbuf_free ( struct mbuf )

References mbuf::buf, MBUF_FREE, and mbuf_init().

Referenced by mg_send_dns_query().

void mbuf_init ( struct mbuf ,
size_t  initial_capacity 
)
size_t mbuf_insert ( struct mbuf ,
size_t  ,
const void *  ,
size_t   
)
void mbuf_remove ( struct mbuf ,
size_t  data_size 
)

References mbuf::buf, and mbuf::len.

Referenced by http_handler(), and mg_forward().

void mbuf_resize ( struct mbuf ,
size_t  new_size 
)

References mbuf::buf, mbuf::len, MBUF_REALLOC, and mbuf::size.

Referenced by mbuf_init(), and mbuf_trim().

void mbuf_trim ( struct mbuf )

References mbuf::len, and mbuf_resize().

void MD5_Final ( unsigned char *  md,
MD5_CTX c 
)
void MD5_Init ( MD5_CTX c)

References MD5Context::bits, and MD5Context::buf.

Referenced by cs_md5().

void MD5_Update ( MD5_CTX c,
const unsigned char *  data,
size_t  len 
)

References MD5Context::bits, MD5Context::buf, if(), and MD5Context::in.

Referenced by cs_md5().

struct mg_connection* mg_add_sock ( struct mg_mgr ,
sock_t  ,
mg_event_handler_t   
)

References mg_add_sock_opt().

struct mg_connection* mg_add_sock_opt ( struct mg_mgr ,
sock_t  ,
mg_event_handler_t  ,
struct mg_add_sock_opts   
)
int mg_avprintf ( char **  buf,
size_t  size,
const char *  fmt,
va_list  ap 
)
int mg_base64_decode ( const unsigned char *  s,
int  len,
char *  dst 
)

References cs_base64_decode().

void mg_base64_encode ( const unsigned char *  src,
int  src_len,
char *  dst 
)
struct mg_connection* mg_bind ( struct mg_mgr ,
const char *  ,
mg_event_handler_t   
)

References mg_bind_opt().

void mg_broadcast ( struct mg_mgr ,
mg_event_handler_t  func,
void *  ,
size_t   
)
int mg_casecmp ( const char *  s1,
const char *  s2 
)

References mg_ncasecmp().

int mg_check_ip_acl ( const char *  acl,
uint32_t  remote_ip 
)

References mg_next_comma_list_entry(), and mg_str::p.

Referenced by mg_send_http_file().

void mg_close_conn ( struct mg_connection nc)
struct mg_connection* mg_connect ( struct mg_mgr ,
const char *  ,
mg_event_handler_t   
)
struct mg_connection* mg_connect_http ( struct mg_mgr ,
mg_event_handler_t  event_handler,
const char *  url,
const char *  extra_headers,
const char *  post_data 
)
int mg_dns_copy_body ( struct mbuf ,
struct mg_dns_message  
)
int mg_dns_encode_record ( struct mbuf ,
struct mg_dns_resource_record ,
const char *  ,
size_t  ,
const void *  ,
size_t   
)
int mg_dns_insert_header ( struct mbuf ,
size_t  ,
struct mg_dns_message  
)
size_t mg_dns_uncompress_name ( struct mg_dns_message ,
struct mg_str ,
char *  ,
int   
)
void mg_enable_multithreading ( struct mg_connection nc)
FILE* mg_fopen ( const char *  path,
const char *  mode 
)

References ARRAY_SIZE, and MAX_PATH_SIZE.

struct mg_str* mg_get_http_header ( struct http_message hm,
const char *  name 
)
int mg_get_http_var ( const struct mg_str ,
const char *  ,
char *  dst,
size_t   
)

References mg_str::len, mg_ncasecmp(), and mg_str::p.

int mg_hexdump ( const void *  buf,
int  len,
char *  dst,
int  dst_len 
)

References mg_str::len.

Referenced by mg_hexdump_connection().

void mg_hexdump_connection ( struct mg_connection nc,
const char *  path,
int  num_bytes,
int  ev 
)
int mg_http_create_digest_auth_header ( char *  buf,
size_t  buf_len,
const char *  method,
const char *  uri,
const char *  auth_domain,
const char *  user,
const char *  passwd 
)

References cs_md5().

int mg_http_parse_header ( struct mg_str hdr,
const char *  var_name,
char *  buf,
size_t  buf_size 
)

References mg_str::len, and mg_str::p.

Referenced by mg_parse_multipart().

void mg_if_connect_cb ( struct mg_connection nc,
int  err 
)
void mg_if_connect_udp ( struct mg_connection nc)
int mg_if_listen_tcp ( struct mg_connection nc,
union socket_address sa 
)

Referenced by mg_bind_opt().

int mg_if_listen_udp ( struct mg_connection nc,
union socket_address sa 
)

Referenced by mg_bind_opt().

void mg_if_poll ( struct mg_connection nc,
time_t  now 
)

References mg_call(), and MG_EV_POLL.

Referenced by mg_mgr_handle_conn().

void mg_if_recv_tcp_cb ( struct mg_connection nc,
void *  buf,
int  len 
)

References mg_if_recved().

void mg_if_recved ( struct mg_connection nc,
size_t  len 
)
void mg_if_sent_cb ( struct mg_connection nc,
int  num_sent 
)
void mg_if_tcp_send ( struct mg_connection nc,
const void *  buf,
size_t  len 
)

References mbuf_append(), and mg_connection::send_mbuf.

Referenced by mg_send().

void mg_if_udp_send ( struct mg_connection nc,
const void *  buf,
size_t  len 
)

References DBG, mbuf::len, mbuf_append(), and mg_connection::send_mbuf.

Referenced by mg_send().

int mg_is_big_endian ( void  )
int mg_match_prefix ( const char *  pattern,
int  pattern_len,
const char *  str 
)

References mbuf::len, and mg_match_prefix().

Referenced by mg_match_prefix(), and mg_send_http_file().

void mg_mgr_init ( struct mg_mgr mgr,
void *  user_data 
)
void mg_mqtt_connack ( struct mg_connection ,
uint8_t   
)

References MG_MQTT_CMD_CONNACK, and mg_send().

void mg_mqtt_disconnect ( struct mg_connection nc)
int mg_mqtt_next_subscribe_topic ( struct mg_mqtt_message ,
struct mg_str ,
uint8_t *  ,
int   
)
void mg_mqtt_ping ( struct mg_connection )

References MG_MQTT_CMD_PINGREQ.

void mg_mqtt_pong ( struct mg_connection )

References MG_MQTT_CMD_PINGRESP.

void mg_mqtt_puback ( struct mg_connection ,
uint16_t   
)

References MG_MQTT_CMD_PUBACK.

void mg_mqtt_pubcomp ( struct mg_connection ,
uint16_t   
)

References MG_MQTT_CMD_PUBCOMP.

void mg_mqtt_publish ( struct mg_connection nc,
const char *  topic,
uint16_t  message_id,
int  flags,
const void *  data,
size_t  len 
)
void mg_mqtt_pubrec ( struct mg_connection ,
uint16_t   
)

References MG_MQTT_CMD_PUBREC.

void mg_mqtt_pubrel ( struct mg_connection ,
uint16_t   
)

References MG_MQTT_CMD_PUBREL.

void mg_mqtt_suback ( struct mg_connection ,
uint8_t *  ,
size_t  ,
uint16_t   
)
void mg_mqtt_subscribe ( struct mg_connection nc,
const struct mg_mqtt_topic_expression topics,
size_t  topics_len,
uint16_t  message_id 
)
void mg_mqtt_unsuback ( struct mg_connection ,
uint16_t   
)

References MG_MQTT_CMD_UNSUBACK.

void mg_mqtt_unsubscribe ( struct mg_connection nc,
char **  topics,
size_t  topics_len,
uint16_t  message_id 
)
int mg_ncasecmp ( const char *  s1,
const char *  s2,
size_t  len 
)
struct mg_connection* mg_next ( struct mg_mgr ,
struct mg_connection  
)
const char* mg_next_comma_list_entry ( const char *  list,
struct mg_str val,
struct mg_str eq_val 
)

References mg_str::len, and mg_str::p.

Referenced by find_index_file(), and mg_check_ip_acl().

int mg_open ( const char *  path,
int  flag,
int  mode 
)

References ARRAY_SIZE, and MAX_PATH_SIZE.

size_t mg_parse_multipart ( const char *  buf,
size_t  buf_len,
char *  var_name,
size_t  var_name_len,
char *  file_name,
size_t  file_name_len,
const char **  chunk,
size_t *  chunk_len 
)
int mg_printf ( struct mg_connection ,
const char *  fmt,
  ... 
)
void mg_printf_html_escape ( struct mg_connection ,
const char *  ,
  ... 
)
void mg_printf_http_chunk ( struct mg_connection ,
const char *  ,
  ... 
)
void mg_printf_websocket_frame ( struct mg_connection nc,
int  op_and_flags,
const char *  fmt,
  ... 
)
int mg_resolve ( const char *  domain_name,
char *  ip_addr_buf,
size_t  buf_len 
)
int mg_resolve_async ( struct mg_mgr ,
const char *  ,
int  ,
mg_resolve_callback_t  ,
void *  data 
)

References mg_resolve_async_opt().

Referenced by mg_connect_opt().

int mg_resolve_from_hosts_file ( const char *  host,
union socket_address usa 
)

References socket_address::sin.

Referenced by mg_parse_address().

int mg_rpc_create_error ( char *  buf,
int  len,
struct mg_rpc_request req,
int  code,
const char *  message,
const char *  fmt,
  ... 
)
int mg_rpc_create_reply ( char *  buf,
int  len,
const struct mg_rpc_request req,
const char *  result_fmt,
  ... 
)
int mg_rpc_create_request ( char *  buf,
int  len,
const char *  method,
const char *  id,
const char *  params_fmt,
  ... 
)

References json_emit(), and json_emit_va().

int mg_rpc_create_std_error ( char *  ,
int  ,
struct mg_rpc_request ,
int  code 
)
int mg_rpc_parse_reply ( const char *  buf,
int  len,
struct json_token toks,
int  max_toks,
struct mg_rpc_reply ,
struct mg_rpc_error  
)
void mg_send_head ( struct mg_connection n,
int  status_code,
int64_t  content_length,
const char *  extra_headers 
)
void mg_send_http_chunk ( struct mg_connection nc,
const char *  buf,
size_t  len 
)

References mg_send().

Referenced by mg_printf_http_chunk().

void mg_send_mqtt_handshake ( struct mg_connection nc,
const char *  client_id 
)
void mg_send_mqtt_handshake_opt ( struct mg_connection ,
const char *  client_id,
struct mg_send_mqtt_handshake_opts   
)
void mg_send_response_line ( struct mg_connection c,
int  status_code,
const char *  extra_headers 
)

References mg_printf().

Referenced by mg_send_head().

void mg_send_websocket_frame ( struct mg_connection nc,
int  op_and_flags,
const void *  data,
size_t  data_len 
)
void mg_send_websocket_framev ( struct mg_connection nc,
int  op_and_flags,
const struct mg_str strings,
int  num_strings 
)
void mg_send_websocket_handshake ( struct mg_connection nc,
const char *  uri,
const char *  extra_headers 
)

References mg_base64_encode(), and mg_printf().

void mg_set_close_on_exec ( sock_t  )

Referenced by mg_socketpair().

void mg_set_protocol_dns ( struct mg_connection )
void mg_set_protocol_http_websocket ( struct mg_connection nc)
void mg_set_protocol_mqtt ( struct mg_connection )
const char* mg_set_ssl ( struct mg_connection nc,
const char *  cert,
const char *  ca_cert 
)

Referenced by mg_connect_http().

const char* mg_skip ( const char *  s,
const char *  end_string,
const char *  delimiters,
struct mg_str v 
)

References mg_str::len, and mg_str::p.

Referenced by mg_parse_http().

void mg_sock_addr_to_str ( const union socket_address sa,
char *  buf,
size_t  len,
int  flags 
)
void mg_sock_to_str ( sock_t  sock,
char *  buf,
size_t  len,
int  flags 
)
int mg_socketpair ( sock_t  [2],
int  sock_type 
)
int mg_stat ( const char *  path,
cs_stat_t st 
)

References ARRAY_SIZE, DBG, and MAX_PATH_SIZE.

Referenced by find_index_file(), and mg_send_http_file().

int mg_vcasecmp ( const struct mg_str str2,
const char *  str1 
)
int mg_vcmp ( const struct mg_str str2,
const char *  str1 
)

References mg_str::len, and mg_str::p.

Referenced by mg_send_http_file(), and mg_serve_http().

int mg_vprintf ( struct mg_connection ,
const char *  fmt,
va_list  ap 
)
int parse_json ( const char *  json_string,
int  json_string_length,
struct json_token tokens_array,
int  size_of_tokens_array 
)

References TRY.

Referenced by mg_rpc_dispatch(), and mg_rpc_parse_reply().

struct json_token* parse_json2 ( const char *  json_string,
int  string_length 
)

References FROZEN_FREE.

size_t strnlen ( const char *  s,
size_t  maxlen 
)

Referenced by c_vsnprintf().

Variable Documentation

enum cs_log_level s_cs_log_level