Teonet library
0.4.7
|
#include "mongoose.h"
#include <string.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
Macros | |
#define | MG_INTERNAL_HEADER_INCLUDED |
#define | MG_MALLOC malloc |
#define | MG_CALLOC calloc |
#define | MG_REALLOC realloc |
#define | MG_FREE free |
#define | MBUF_REALLOC MG_REALLOC |
#define | MBUF_FREE MG_FREE |
#define | MG_SET_PTRPTR(_ptr, _v) |
#define | MG_INTERNAL static |
#define | MG_MGR_EV_MGR 0 /* select() */ |
#define | NUM_UPPERCASES ('Z' - 'A' + 1) |
#define | NUM_LETTERS (NUM_UPPERCASES * 2) |
#define | NUM_DIGITS ('9' - '0' + 1) |
#define | BASE64_ENCODE_BODY |
#define | BASE64_OUT(ch) |
#define | BASE64_FLUSH() |
#define | BASE64_OUT(ch) |
#define | BASE64_FLUSH() |
#define | _CRT_SECURE_NO_WARNINGS /* Disable deprecation warning in VS2005+ */ |
#define | FROZEN_REALLOC realloc |
#define | FROZEN_FREE free |
#define | EXPECT(cond, err_code) do { if (!(cond)) return (err_code); } while (0) |
#define | TRY(expr) do { int _n = expr; if (_n < 0) return _n; } while (0) |
#define | END_OF_STRING (-1) |
#define | EMIT(x) do { if (s < end) *s = x; s++; } while (0) |
#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) |
#define | SHA1HANDSOFF |
#define | rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits)))) |
#define | blk(i) |
#define | R0(v, w, x, y, z, i) |
#define | R1(v, w, x, y, z, i) |
#define | R2(v, w, x, y, z, i) |
#define | R3(v, w, x, y, z, i) |
#define | R4(v, w, x, y, z, i) |
#define | C_SNPRINTF_APPEND_CHAR(ch) |
#define | C_SNPRINTF_FLAG_ZERO 1 |
#define | MG_CTL_MSG_MESSAGE_SIZE 8192 |
#define | MG_VPRINTF_BUFFER_SIZE 100 |
#define | MG_MAX_HOST_LEN 200 |
#define | MG_COPY_COMMON_CONNECTION_OPTIONS(dst, src) memcpy(dst, src, sizeof(*dst)); |
#define | _MG_ALLOWED_CONNECT_FLAGS_MASK |
#define | _MG_CALLBACK_MODIFIABLE_FLAGS_MASK |
#define | intptr_t long |
#define | MG_TCP_RECV_BUFFER_SIZE 1024 |
#define | MG_UDP_RECV_BUFFER_SIZE 1500 |
#define | _MG_F_FD_CAN_READ 1 |
#define | _MG_F_FD_CAN_WRITE 1 << 1 |
#define | _MG_F_FD_ERROR 1 << 2 |
#define | MIME_ENTRY(_ext, _type) { _ext, sizeof(_ext) - 1, _type } |
#define | HEXTOI(x) (isdigit(x) ? x - '0' : x - 'W') |
#define | MG_DEFAULT_NAMESERVER "8.8.8.8" |
Enumerations | |
enum | http_proto_data_type { DATA_NONE, DATA_FILE, DATA_PUT, DATA_CGI } |
Functions | |
MG_INTERNAL struct mg_connection * | mg_do_connect (struct mg_connection *nc, int proto, union socket_address *sa) |
MG_INTERNAL int | mg_parse_address (const char *str, union socket_address *sa, int *proto, char *host, size_t host_len) |
MG_INTERNAL void | mg_call (struct mg_connection *nc, mg_event_handler_t ev_handler, int ev, void *ev_data) |
MG_INTERNAL void | mg_forward (struct mg_connection *, struct mg_connection *) |
MG_INTERNAL void | mg_add_conn (struct mg_mgr *mgr, struct mg_connection *c) |
MG_INTERNAL void | mg_remove_conn (struct mg_connection *c) |
MG_INTERNAL int | find_index_file (char *, size_t, const char *, cs_stat_t *) |
MG_INTERNAL size_t | mg_handle_chunked (struct mg_connection *nc, struct http_message *hm, char *buf, size_t blen) |
MG_INTERNAL time_t | mg_parse_date_string (const char *datetime) |
MG_INTERNAL int | mg_is_not_modified (struct http_message *hm, cs_stat_t *st) |
void | cs_base64_init (struct cs_base64_ctx *ctx, cs_base64_putc_t b64_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) |
void | cs_log_printf (const char *fmt,...) |
void | cs_log_set_level (enum cs_log_level level) |
int | parse_json (const char *s, int s_len, struct json_token *arr, int arr_len) |
struct json_token * | parse_json2 (const char *s, int s_len) |
struct json_token * | find_json_token (struct json_token *toks, const char *path) |
int | json_emit_long (char *buf, int buf_len, long int value) |
int | json_emit_double (char *buf, int buf_len, double value) |
int | json_emit_quoted_str (char *s, int s_len, const char *str, int len) |
int | json_emit_unquoted_str (char *buf, int buf_len, const char *str, int len) |
int | json_emit_va (char *s, int s_len, const char *fmt, va_list ap) |
int | json_emit (char *buf, int buf_len, const char *fmt,...) |
void | MD5_Init (MD5_CTX *ctx) |
void | MD5_Update (MD5_CTX *ctx, const unsigned char *buf, size_t len) |
void | MD5_Final (unsigned char digest[16], MD5_CTX *ctx) |
void | cs_to_hex (char *to, const unsigned char *p, size_t len) |
char * | cs_md5 (char buf[33],...) |
void | mbuf_init (struct mbuf *mbuf, size_t initial_size) |
void | mbuf_free (struct mbuf *mbuf) |
void | mbuf_resize (struct mbuf *a, size_t new_size) |
void | mbuf_trim (struct mbuf *mbuf) |
size_t | mbuf_insert (struct mbuf *a, size_t off, const void *buf, size_t len) |
size_t | mbuf_append (struct mbuf *a, const void *buf, size_t len) |
void | mbuf_remove (struct mbuf *mb, size_t n) |
void | cs_sha1_transform (uint32_t state[5], const unsigned char buffer[64]) |
void | cs_sha1_init (cs_sha1_ctx *context) |
void | cs_sha1_update (cs_sha1_ctx *context, const unsigned char *data, uint32_t len) |
void | cs_sha1_final (unsigned char digest[20], cs_sha1_ctx *context) |
void | cs_hmac_sha1 (const unsigned char *key, size_t keylen, const unsigned char *data, size_t datalen, unsigned char out[20]) |
size_t | strnlen (const char *s, size_t maxlen) |
int | c_vsnprintf (char *buf, size_t buf_size, const char *fmt, va_list ap) |
int | c_snprintf (char *buf, size_t buf_size, const char *fmt,...) |
int | mg_is_error (int n) |
void | mg_set_non_blocking_mode (sock_t sock) |
void | mg_ev_mgr_init (struct mg_mgr *mgr) |
void | mg_ev_mgr_free (struct mg_mgr *mgr) |
void | mg_ev_mgr_add_conn (struct mg_connection *nc) |
void | mg_ev_mgr_remove_conn (struct mg_connection *nc) |
void | mg_if_poll (struct mg_connection *nc, time_t now) |
void | mg_close_conn (struct mg_connection *conn) |
void | mg_mgr_init (struct mg_mgr *m, void *user_data) |
void | mg_mgr_free (struct mg_mgr *m) |
int | mg_vprintf (struct mg_connection *nc, const char *fmt, va_list ap) |
int | mg_printf (struct mg_connection *conn, const char *fmt,...) |
int | mg_resolve (const char *host, char *buf, size_t n) |
MG_INTERNAL struct mg_connection * | mg_create_connection (struct mg_mgr *mgr, mg_event_handler_t callback, struct mg_add_sock_opts opts) |
struct mg_connection * | mg_if_accept_tcp_cb (struct mg_connection *lc, union socket_address *sa, size_t sa_len) |
void | mg_send (struct mg_connection *nc, const void *buf, int 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_connect_cb (struct mg_connection *nc, int err) |
struct mg_connection * | mg_connect (struct mg_mgr *mgr, const char *address, mg_event_handler_t callback) |
struct mg_connection * | mg_connect_opt (struct mg_mgr *mgr, const char *address, mg_event_handler_t callback, struct mg_connect_opts opts) |
struct mg_connection * | mg_bind (struct mg_mgr *srv, const char *address, mg_event_handler_t event_handler) |
struct mg_connection * | mg_bind_opt (struct mg_mgr *mgr, const char *address, mg_event_handler_t callback, struct mg_bind_opts opts) |
struct mg_connection * | mg_next (struct mg_mgr *s, struct mg_connection *conn) |
void | mg_broadcast (struct mg_mgr *mgr, mg_event_handler_t cb, void *data, size_t len) |
int | mg_check_ip_acl (const char *acl, uint32_t remote_ip) |
void | mg_if_connect_tcp (struct mg_connection *nc, const union socket_address *sa) |
void | mg_if_connect_udp (struct mg_connection *nc) |
int | mg_if_listen_tcp (struct mg_connection *nc, union socket_address *sa) |
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_recved (struct mg_connection *nc, size_t len) |
void | mg_if_destroy_conn (struct mg_connection *nc) |
void | mg_mgr_handle_conn (struct mg_connection *nc, int fd_flags, time_t now) |
struct mg_connection * | mg_add_sock (struct mg_mgr *s, sock_t sock, mg_event_handler_t callback) |
struct mg_connection * | mg_add_sock_opt (struct mg_mgr *s, sock_t sock, mg_event_handler_t callback, struct mg_add_sock_opts opts) |
void | mg_add_to_set (sock_t sock, fd_set *set, sock_t *max_fd) |
time_t | mg_mgr_poll (struct mg_mgr *mgr, int milli) |
int | mg_socketpair (sock_t sp[2], int sock_type) |
void | mg_sock_to_str (sock_t sock, char *buf, size_t len, int flags) |
int | mg_parse_http (const char *s, int n, struct http_message *hm, int is_req) |
struct mg_str * | mg_get_http_header (struct http_message *hm, const char *name) |
void | mg_send_websocket_frame (struct mg_connection *nc, int op, const void *data, size_t len) |
void | mg_send_websocket_framev (struct mg_connection *nc, int op, const struct mg_str *strv, int strvcnt) |
void | mg_printf_websocket_frame (struct mg_connection *nc, int op, const char *fmt,...) |
void | http_handler (struct mg_connection *nc, int ev, void *ev_data) |
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_response_line (struct mg_connection *nc, int status_code, const char *extra_headers) |
void | mg_send_head (struct mg_connection *c, int status_code, int64_t content_length, const char *extra_headers) |
int | mg_get_http_var (const struct mg_str *buf, const char *name, char *dst, size_t dst_len) |
void | mg_send_http_chunk (struct mg_connection *nc, const char *buf, size_t len) |
void | mg_printf_http_chunk (struct mg_connection *nc, const char *fmt,...) |
void | mg_printf_html_escape (struct mg_connection *nc, const char *fmt,...) |
int | mg_http_parse_header (struct mg_str *hdr, const char *var_name, char *buf, size_t buf_size) |
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) |
void | mg_send_http_file (struct mg_connection *nc, char *path, size_t path_buf_len, struct http_message *hm, struct mg_serve_http_opts *opts) |
void | mg_serve_http (struct mg_connection *nc, struct http_message *hm, struct mg_serve_http_opts opts) |
struct mg_connection * | mg_connect_http (struct mg_mgr *mgr, mg_event_handler_t ev_handler, const char *url, const char *extra_headers, const char *post_data) |
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 **data, size_t *data_len) |
const char * | mg_skip (const char *s, const char *end, const char *delims, 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_vcasecmp (const struct mg_str *str1, const char *str2) |
int | mg_vcmp (const struct mg_str *str1, const char *str2) |
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_base64_encode (const unsigned char *src, int src_len, char *dst) |
int | mg_base64_decode (const unsigned char *s, int len, char *dst) |
void | mg_set_close_on_exec (sock_t sock) |
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) |
int | mg_avprintf (char **buf, size_t size, const char *fmt, va_list ap) |
void | mg_hexdump_connection (struct mg_connection *nc, const char *path, int num_bytes, int ev) |
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) |
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,...) |
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 *buf, int len, struct mg_rpc_request *req, int code) |
int | mg_rpc_dispatch (const char *buf, int len, char *dst, int dst_len, const char **methods, mg_rpc_handler_t *handlers) |
int | mg_rpc_parse_reply (const char *buf, int len, struct json_token *toks, int max_toks, struct mg_rpc_reply *rep, struct mg_rpc_error *er) |
void | mg_set_protocol_mqtt (struct mg_connection *nc) |
void | mg_send_mqtt_handshake (struct mg_connection *nc, const char *client_id) |
void | mg_send_mqtt_handshake_opt (struct mg_connection *nc, const char *client_id, struct mg_send_mqtt_handshake_opts 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) |
int | mg_mqtt_next_subscribe_topic (struct mg_mqtt_message *msg, struct mg_str *topic, uint8_t *qos, int pos) |
void | mg_mqtt_unsubscribe (struct mg_connection *nc, char **topics, size_t topics_len, uint16_t message_id) |
void | mg_mqtt_connack (struct mg_connection *nc, uint8_t return_code) |
void | mg_mqtt_puback (struct mg_connection *nc, uint16_t message_id) |
void | mg_mqtt_pubrec (struct mg_connection *nc, uint16_t message_id) |
void | mg_mqtt_pubrel (struct mg_connection *nc, uint16_t message_id) |
void | mg_mqtt_pubcomp (struct mg_connection *nc, uint16_t message_id) |
void | mg_mqtt_suback (struct mg_connection *nc, uint8_t *qoss, size_t qoss_len, uint16_t message_id) |
void | mg_mqtt_unsuback (struct mg_connection *nc, uint16_t message_id) |
void | mg_mqtt_ping (struct mg_connection *nc) |
void | mg_mqtt_pong (struct mg_connection *nc) |
void | mg_mqtt_disconnect (struct mg_connection *nc) |
struct mg_dns_resource_record * | mg_dns_next_record (struct mg_dns_message *msg, int query, struct mg_dns_resource_record *prev) |
int | mg_dns_parse_record_data (struct mg_dns_message *msg, struct mg_dns_resource_record *rr, void *data, size_t data_len) |
int | mg_dns_insert_header (struct mbuf *io, size_t pos, struct mg_dns_message *msg) |
int | mg_dns_copy_body (struct mbuf *io, struct mg_dns_message *msg) |
int | mg_dns_encode_record (struct mbuf *io, struct mg_dns_resource_record *rr, const char *name, size_t nlen, const void *rdata, size_t rlen) |
void | mg_send_dns_query (struct mg_connection *nc, const char *name, int query_type) |
int | mg_parse_dns (const char *buf, int len, struct mg_dns_message *msg) |
size_t | mg_dns_uncompress_name (struct mg_dns_message *msg, struct mg_str *name, char *dst, int dst_len) |
void | mg_set_protocol_dns (struct mg_connection *nc) |
int | mg_resolve_from_hosts_file (const char *name, union socket_address *usa) |
int | mg_resolve_async (struct mg_mgr *mgr, const char *name, int query, mg_resolve_callback_t cb, void *data) |
int | mg_resolve_async_opt (struct mg_mgr *mgr, const char *name, int query, mg_resolve_callback_t cb, void *data, struct mg_resolve_async_opts opts) |
Variables | |
void *(* | test_malloc )(size_t) |
void *(* | test_calloc )(size_t, size_t) |
enum cs_log_level | s_cs_log_level |
MG_INTERNAL char | mg_dns_server [256] |
#define _CRT_SECURE_NO_WARNINGS /* Disable deprecation warning in VS2005+ */ |
#define _MG_ALLOWED_CONNECT_FLAGS_MASK |
Referenced by mg_connect_opt(), and mg_create_connection().
#define _MG_CALLBACK_MODIFIABLE_FLAGS_MASK |
Referenced by mg_call().
#define _MG_F_FD_CAN_READ 1 |
Referenced by mg_mgr_handle_conn(), and mg_mgr_poll().
#define _MG_F_FD_CAN_WRITE 1 << 1 |
Referenced by mg_mgr_handle_conn(), and mg_mgr_poll().
#define _MG_F_FD_ERROR 1 << 2 |
Referenced by mg_mgr_poll().
#define BASE64_ENCODE_BODY |
Referenced by cs_base64_encode(), and cs_fprint_base64().
#define BASE64_FLUSH | ( | ) |
#define BASE64_FLUSH | ( | ) |
#define BASE64_OUT | ( | ch | ) |
#define BASE64_OUT | ( | ch | ) |
#define blk | ( | i | ) |
#define C_SNPRINTF_APPEND_CHAR | ( | ch | ) |
Referenced by c_vsnprintf().
#define C_SNPRINTF_FLAG_ZERO 1 |
Referenced by c_vsnprintf().
#define EMIT | ( | x | ) | do { if (s < end) *s = x; s++; } while (0) |
Referenced by json_emit_quoted_str().
#define END_OF_STRING (-1) |
#define EXPECT | ( | cond, | |
err_code | |||
) | do { if (!(cond)) return (err_code); } while (0) |
#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 FROZEN_FREE free |
Referenced by parse_json2().
#define FROZEN_REALLOC realloc |
#define HEXTOI | ( | x | ) | (isdigit(x) ? x - '0' : x - 'W') |
#define intptr_t long |
#define MBUF_FREE MG_FREE |
Referenced by mbuf_free().
#define MBUF_REALLOC MG_REALLOC |
Referenced by mbuf_insert(), and mbuf_resize().
#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_CALLOC calloc |
Referenced by mg_create_connection(), mg_handle_chunked(), mg_resolve_async_opt(), and mg_send_dns_query().
#define MG_COPY_COMMON_CONNECTION_OPTIONS | ( | dst, | |
src | |||
) | memcpy(dst, src, sizeof(*dst)); |
Referenced by mg_bind_opt(), and mg_connect_opt().
#define MG_CTL_MSG_MESSAGE_SIZE 8192 |
#define MG_DEFAULT_NAMESERVER "8.8.8.8" |
#define MG_FREE free |
#define MG_INTERNAL static |
#define MG_INTERNAL_HEADER_INCLUDED |
#define MG_MALLOC malloc |
Referenced by mg_avprintf(), and mg_hexdump_connection().
#define MG_MAX_HOST_LEN 200 |
Referenced by mg_bind_opt(), and mg_connect_opt().
#define MG_MGR_EV_MGR 0 /* select() */ |
#define MG_REALLOC realloc |
Referenced by mg_connect_http().
#define MG_SET_PTRPTR | ( | _ptr, | |
_v | |||
) |
Referenced by mg_bind_opt(), mg_connect_opt(), and mg_create_connection().
#define MG_TCP_RECV_BUFFER_SIZE 1024 |
#define MG_UDP_RECV_BUFFER_SIZE 1500 |
#define MG_VPRINTF_BUFFER_SIZE 100 |
Referenced by mg_vprintf().
#define MIME_ENTRY | ( | _ext, | |
_type | |||
) | { _ext, sizeof(_ext) - 1, _type } |
#define NUM_DIGITS ('9' - '0' + 1) |
#define NUM_LETTERS (NUM_UPPERCASES * 2) |
#define NUM_UPPERCASES ('Z' - 'A' + 1) |
#define R0 | ( | v, | |
w, | |||
x, | |||
y, | |||
z, | |||
i | |||
) |
#define R1 | ( | v, | |
w, | |||
x, | |||
y, | |||
z, | |||
i | |||
) |
#define R2 | ( | v, | |
w, | |||
x, | |||
y, | |||
z, | |||
i | |||
) |
#define R3 | ( | v, | |
w, | |||
x, | |||
y, | |||
z, | |||
i | |||
) |
#define R4 | ( | v, | |
w, | |||
x, | |||
y, | |||
z, | |||
i | |||
) |
#define rol | ( | value, | |
bits | |||
) | (((value) << (bits)) | ((value) >> (32 - (bits)))) |
#define SHA1HANDSOFF |
#define TRY | ( | expr | ) | do { int _n = expr; if (_n < 0) return _n; } while (0) |
Referenced by parse_json().
enum http_proto_data_type |
int c_snprintf | ( | char * | buf, |
size_t | buf_size, | ||
const char * | fmt, | ||
... | |||
) |
References c_vsnprintf(), and result.
int c_vsnprintf | ( | char * | buf, |
size_t | buf_size, | ||
const char * | fmt, | ||
va_list | ap | ||
) |
References C_SNPRINTF_APPEND_CHAR, C_SNPRINTF_FLAG_ZERO, and strnlen().
Referenced by c_snprintf().
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_finish | ( | struct cs_base64_ctx * | ctx | ) |
void cs_base64_init | ( | struct cs_base64_ctx * | ctx, |
cs_base64_putc_t | b64_putc, | ||
void * | user_data | ||
) |
void cs_base64_update | ( | struct cs_base64_ctx * | ctx, |
const char * | str, | ||
size_t | len | ||
) |
References cs_base64_ctx::chunk, and cs_base64_ctx::chunk_size.
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 | keylen, | ||
const unsigned char * | data, | ||
size_t | datalen, | ||
unsigned char | out[20] | ||
) |
References cs_sha1_final(), cs_sha1_init(), and cs_sha1_update().
void cs_log_printf | ( | const char * | fmt, |
... | |||
) |
void cs_log_set_level | ( | enum cs_log_level | level | ) |
char* cs_md5 | ( | char | buf[33], |
... | |||
) |
References cs_to_hex(), MD5_Final(), MD5_Init(), and MD5_Update().
Referenced by mg_http_create_digest_auth_header().
void cs_sha1_final | ( | unsigned char | digest[20], |
cs_sha1_ctx * | context | ||
) |
References cs_sha1_ctx::count, cs_sha1_update(), and cs_sha1_ctx::state.
Referenced by cs_hmac_sha1().
void cs_sha1_init | ( | cs_sha1_ctx * | context | ) |
References cs_sha1_ctx::count, and cs_sha1_ctx::state.
Referenced by cs_hmac_sha1().
void cs_sha1_transform | ( | uint32_t | state[5], |
const unsigned char | buffer[64] | ||
) |
void cs_sha1_update | ( | cs_sha1_ctx * | context, |
const unsigned char * | data, | ||
uint32_t | len | ||
) |
References cs_sha1_ctx::buffer, cs_sha1_ctx::count, cs_sha1_transform(), and cs_sha1_ctx::state.
Referenced by cs_hmac_sha1(), and cs_sha1_final().
void cs_to_hex | ( | char * | to, |
const unsigned char * | p, | ||
size_t | len | ||
) |
Referenced by cs_md5().
MG_INTERNAL int find_index_file | ( | char * | path, |
size_t | path_len, | ||
const char * | list, | ||
cs_stat_t * | stp | ||
) |
References mg_str::len, mg_next_comma_list_entry(), mg_stat(), and mg_str::p.
Referenced by mg_send_http_file().
struct json_token* find_json_token | ( | struct json_token * | toks, |
const char * | path | ||
) |
References JSON_TYPE_ARRAY, JSON_TYPE_OBJECT, JSON_TYPE_STRING, json_token::num_desc, and json_token::type.
Referenced by mg_rpc_dispatch(), and mg_rpc_parse_reply().
void http_handler | ( | struct mg_connection * | nc, |
int | ev, | ||
void * | ev_data | ||
) |
References http_message::body, mbuf::buf, DBG, mg_connection::flags, mg_connection::handler, http_message::header_names, http_message::header_values, mbuf::len, mg_str::len, mg_connection::listener, mbuf_remove(), http_message::message, http_message::method, mg_call(), MG_EV_CLOSE, MG_EV_HTTP_REPLY, MG_EV_HTTP_REQUEST, MG_EV_RECV, MG_EV_WEBSOCKET_HANDSHAKE_DONE, MG_EV_WEBSOCKET_HANDSHAKE_REQUEST, MG_F_CLOSE_IMMEDIATELY, MG_F_IS_WEBSOCKET, MG_F_SEND_AND_CLOSE, mg_get_http_header(), mg_handle_chunked(), MG_MAX_HTTP_REQUEST_SIZE, mg_parse_http(), mg_vcasecmp(), mg_connection::mgr, mg_str::p, mg_connection::proto_data, mg_connection::proto_handler, mg_connection::recv_mbuf, mg_connection::send_mbuf, and http_message::uri.
Referenced by mg_set_protocol_http_websocket().
int json_emit | ( | char * | buf, |
int | buf_len, | ||
const char * | fmt, | ||
... | |||
) |
References json_emit_va(), and json_token::len.
Referenced by mg_rpc_create_error(), mg_rpc_create_reply(), and mg_rpc_create_request().
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 int | value | ||
) |
Referenced by json_emit_va().
int json_emit_quoted_str | ( | char * | s, |
int | s_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 * | s, |
int | s_len, | ||
const char * | fmt, | ||
va_list | ap | ||
) |
References json_emit_double(), json_emit_long(), json_emit_quoted_str(), json_emit_unquoted_str(), and json_token::len.
Referenced by json_emit(), mg_rpc_create_error(), mg_rpc_create_reply(), and mg_rpc_create_request().
size_t mbuf_append | ( | struct mbuf * | a, |
const void * | buf, | ||
size_t | len | ||
) |
References mbuf::len, and mbuf_insert().
Referenced by mg_dns_copy_body(), mg_dns_encode_record(), mg_if_tcp_send(), and mg_if_udp_send().
void mbuf_free | ( | struct mbuf * | mbuf | ) |
References mbuf::buf, MBUF_FREE, and mbuf_init().
Referenced by mg_send_dns_query().
void mbuf_init | ( | struct mbuf * | mbuf, |
size_t | initial_size | ||
) |
References mbuf::buf, mbuf::len, mbuf_resize(), and mbuf::size.
Referenced by mbuf_free(), and mg_send_dns_query().
size_t mbuf_insert | ( | struct mbuf * | a, |
size_t | off, | ||
const void * | buf, | ||
size_t | len | ||
) |
References mbuf::buf, mbuf::len, json_token::len, MBUF_REALLOC, MBUF_SIZE_MULTIPLIER, and mbuf::size.
Referenced by mbuf_append(), mg_dns_insert_header(), and mg_send_dns_query().
void mbuf_remove | ( | struct mbuf * | mb, |
size_t | n | ||
) |
References mbuf::buf, and mbuf::len.
Referenced by http_handler(), and mg_forward().
void mbuf_resize | ( | struct mbuf * | a, |
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 * | mbuf | ) |
References mbuf::len, and mbuf_resize().
void MD5_Final | ( | unsigned char | digest[16], |
MD5_CTX * | ctx | ||
) |
References MD5Context::bits, MD5Context::buf, and MD5Context::in.
Referenced by cs_md5().
void MD5_Init | ( | MD5_CTX * | ctx | ) |
References MD5Context::bits, and MD5Context::buf.
Referenced by cs_md5().
void MD5_Update | ( | MD5_CTX * | ctx, |
const unsigned char * | buf, | ||
size_t | len | ||
) |
References MD5Context::bits, MD5Context::buf, if(), and MD5Context::in.
Referenced by cs_md5().
MG_INTERNAL void mg_add_conn | ( | struct mg_mgr * | mgr, |
struct mg_connection * | c | ||
) |
References mg_mgr::active_connections, DBG, mg_ev_mgr_add_conn(), mg_connection::mgr, mg_connection::next, and mg_connection::prev.
Referenced by mg_add_sock_opt(), mg_bind_opt(), mg_do_connect(), mg_if_accept_tcp_cb(), and mg_if_recv_udp_cb().
struct mg_connection* mg_add_sock | ( | struct mg_mgr * | s, |
sock_t | sock, | ||
mg_event_handler_t | callback | ||
) |
References mg_add_sock_opt().
struct mg_connection* mg_add_sock_opt | ( | struct mg_mgr * | s, |
sock_t | sock, | ||
mg_event_handler_t | callback, | ||
struct mg_add_sock_opts | opts | ||
) |
References mg_add_conn(), mg_create_connection(), mg_connection::mgr, and nc.
Referenced by mg_add_sock().
References INVALID_SOCKET, and mg_connection::sock.
Referenced by mg_mgr_poll().
int mg_avprintf | ( | char ** | buf, |
size_t | size, | ||
const char * | fmt, | ||
va_list | ap | ||
) |
References mg_str::len, MG_FREE, MG_MALLOC, and va_copy.
Referenced by mg_printf_html_escape(), mg_printf_http_chunk(), mg_printf_websocket_frame(), and mg_vprintf().
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 | ||
) |
References cs_base64_encode().
Referenced by mg_send_websocket_handshake().
struct mg_connection* mg_bind | ( | struct mg_mgr * | srv, |
const char * | address, | ||
mg_event_handler_t | event_handler | ||
) |
References mg_bind_opt().
struct mg_connection* mg_bind_opt | ( | struct mg_mgr * | mgr, |
const char * | address, | ||
mg_event_handler_t | callback, | ||
struct mg_bind_opts | opts | ||
) |
References DBG, mg_bind_opts::error_string, mg_connection::flags, mg_add_conn(), MG_COPY_COMMON_CONNECTION_OPTIONS, mg_create_connection(), MG_F_LISTENING, MG_F_UDP, mg_if_listen_tcp(), mg_if_listen_udp(), MG_MAX_HOST_LEN, mg_parse_address(), MG_SET_PTRPTR, mg_connection::mgr, nc, and mg_connection::sa.
Referenced by mg_bind().
void mg_broadcast | ( | struct mg_mgr * | mgr, |
mg_event_handler_t | cb, | ||
void * | data, | ||
size_t | len | ||
) |
References mg_mgr::ctl, INVALID_SOCKET, MG_RECV_FUNC, and MG_SEND_FUNC.
MG_INTERNAL void mg_call | ( | struct mg_connection * | nc, |
mg_event_handler_t | ev_handler, | ||
int | ev, | ||
void * | ev_data | ||
) |
References _MG_CALLBACK_MODIFIABLE_FLAGS_MASK, DBG, mg_connection::flags, mg_connection::handler, mg_mgr::hexdump_file, mbuf::len, MG_EV_POLL, MG_EV_RECV, MG_EV_SEND, mg_hexdump_connection(), mg_connection::mgr, mg_connection::proto_handler, mg_connection::recv_mbuf, and mg_connection::send_mbuf.
Referenced by http_handler(), mg_close_conn(), mg_handle_chunked(), mg_if_accept_tcp_cb(), mg_if_connect_cb(), mg_if_poll(), mg_if_recv_udp_cb(), and mg_if_sent_cb().
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 * | conn | ) |
References DBG, mg_connection::flags, mg_call(), MG_EV_CLOSE, MG_F_CONNECTING, and mg_remove_conn().
Referenced by mg_mgr_free(), and mg_mgr_poll().
struct mg_connection* mg_connect | ( | struct mg_mgr * | mgr, |
const char * | address, | ||
mg_event_handler_t | callback | ||
) |
References mg_connect_opt().
Referenced by mg_connect_http(), and mg_resolve_async_opt().
struct mg_connection* mg_connect_http | ( | struct mg_mgr * | mgr, |
mg_event_handler_t | ev_handler, | ||
const char * | url, | ||
const char * | extra_headers, | ||
const char * | post_data | ||
) |
References DBG, mg_connect(), MG_FREE, mg_printf(), MG_REALLOC, mg_set_protocol_http_websocket(), mg_set_ssl(), nc, and SIZE_T_FMT.
struct mg_connection* mg_connect_opt | ( | struct mg_mgr * | mgr, |
const char * | address, | ||
mg_event_handler_t | callback, | ||
struct mg_connect_opts | opts | ||
) |
References _MG_ALLOWED_CONNECT_FLAGS_MASK, mg_connect_opts::error_string, mg_connection::flags, mg_connect_opts::flags, MG_COPY_COMMON_CONNECTION_OPTIONS, mg_create_connection(), MG_DNS_A_RECORD, mg_do_connect(), MG_F_UDP, MG_MAX_HOST_LEN, mg_parse_address(), mg_resolve_async(), MG_SET_PTRPTR, mg_connection::mgr, nc, mg_connection::sa, mg_connection::user_data, and mg_connect_opts::user_data.
Referenced by mg_connect().
MG_INTERNAL struct mg_connection* mg_create_connection | ( | struct mg_mgr * | mgr, |
mg_event_handler_t | callback, | ||
struct mg_add_sock_opts | opts | ||
) |
References _MG_ALLOWED_CONNECT_FLAGS_MASK, mg_add_sock_opts::error_string, mg_connection::flags, mg_add_sock_opts::flags, mg_connection::handler, INVALID_SOCKET, mg_connection::last_io_time, MG_CALLOC, MG_SET_PTRPTR, mg_connection::mgr, mg_connection::recv_mbuf_limit, mg_connection::sock, mg_connection::user_data, and mg_add_sock_opts::user_data.
Referenced by mg_add_sock_opt(), mg_bind_opt(), mg_connect_opt(), mg_if_accept_tcp_cb(), and mg_if_recv_udp_cb().
int mg_dns_copy_body | ( | struct mbuf * | io, |
struct mg_dns_message * | msg | ||
) |
References mg_str::len, mbuf_append(), mg_str::p, and mg_dns_message::pkt.
int mg_dns_encode_record | ( | struct mbuf * | io, |
struct mg_dns_resource_record * | rr, | ||
const char * | name, | ||
size_t | nlen, | ||
const void * | rdata, | ||
size_t | rlen | ||
) |
int mg_dns_insert_header | ( | struct mbuf * | io, |
size_t | pos, | ||
struct mg_dns_message * | msg | ||
) |
References mg_dns_message::flags, mbuf_insert(), mg_dns_message::num_answers, mg_dns_message::num_questions, and mg_dns_message::transaction_id.
Referenced by mg_send_dns_query().
struct mg_dns_resource_record* mg_dns_next_record | ( | struct mg_dns_message * | msg, |
int | query, | ||
struct mg_dns_resource_record * | prev | ||
) |
References mg_dns_message::answers, mg_dns_message::num_answers, and mg_dns_resource_record::rtype.
int mg_dns_parse_record_data | ( | struct mg_dns_message * | msg, |
struct mg_dns_resource_record * | rr, | ||
void * | data, | ||
size_t | data_len | ||
) |
size_t mg_dns_uncompress_name | ( | struct mg_dns_message * | msg, |
struct mg_str * | name, | ||
char * | dst, | ||
int | dst_len | ||
) |
References mg_str::len, mg_str::p, and mg_dns_message::pkt.
Referenced by mg_dns_parse_record_data().
MG_INTERNAL struct mg_connection * mg_do_connect | ( | struct mg_connection * | nc, |
int | proto, | ||
union socket_address * | sa | ||
) |
References DBG, mg_connection::flags, mg_add_conn(), MG_F_CONNECTING, mg_if_connect_tcp(), mg_if_connect_udp(), mg_connection::mgr, nc, and socket_address::sin.
Referenced by mg_connect_opt().
void mg_ev_mgr_add_conn | ( | struct mg_connection * | nc | ) |
Referenced by mg_add_conn().
void mg_ev_mgr_free | ( | struct mg_mgr * | mgr | ) |
Referenced by mg_mgr_free().
void mg_ev_mgr_init | ( | struct mg_mgr * | mgr | ) |
References mg_mgr::ctl, DBG, INVALID_SOCKET, and mg_socketpair().
Referenced by mg_mgr_init().
void mg_ev_mgr_remove_conn | ( | struct mg_connection * | nc | ) |
Referenced by mg_remove_conn().
FILE* mg_fopen | ( | const char * | path, |
const char * | mode | ||
) |
References ARRAY_SIZE, and MAX_PATH_SIZE.
void mg_forward | ( | struct mg_connection * | from, |
struct mg_connection * | to | ||
) |
References mbuf::buf, mbuf::len, mbuf_remove(), mg_send(), and mg_connection::recv_mbuf.
struct mg_str* mg_get_http_header | ( | struct http_message * | hm, |
const char * | name | ||
) |
References http_message::header_names, http_message::header_values, mg_str::len, mg_ncasecmp(), and mg_str::p.
Referenced by http_handler(), mg_is_not_modified(), and mg_serve_http().
int mg_get_http_var | ( | const struct mg_str * | buf, |
const char * | name, | ||
char * | dst, | ||
size_t | dst_len | ||
) |
References mg_str::len, mg_ncasecmp(), and mg_str::p.
MG_INTERNAL size_t mg_handle_chunked | ( | struct mg_connection * | nc, |
struct http_message * | hm, | ||
char * | buf, | ||
size_t | blen | ||
) |
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().
struct mg_connection* mg_if_accept_tcp_cb | ( | struct mg_connection * | lc, |
union socket_address * | sa, | ||
size_t | sa_len | ||
) |
References DBG, mg_connection::flags, mg_connection::handler, mg_connection::listener, mg_add_conn(), mg_call(), mg_create_connection(), MG_EV_ACCEPT, mg_connection::mgr, nc, mg_connection::proto_data, mg_connection::proto_handler, mg_connection::recv_mbuf_limit, mg_connection::sa, mg_connection::sock, mg_connection::ssl, mg_connection::ssl_ctx, and mg_connection::user_data.
void mg_if_connect_cb | ( | struct mg_connection * | nc, |
int | err | ||
) |
References DBG, mg_connection::flags, mg_call(), MG_EV_CONNECT, MG_F_CLOSE_IMMEDIATELY, MG_F_CONNECTING, mg_connection::sock, and mg_connection::ssl.
Referenced by mg_mgr_handle_conn().
void mg_if_connect_tcp | ( | struct mg_connection * | nc, |
const union socket_address * | sa | ||
) |
References DBG, mg_connection::err, INVALID_SOCKET, mg_is_error(), mg_set_non_blocking_mode(), socket_address::sa, socket_address::sin, and mg_connection::sock.
Referenced by mg_do_connect().
void mg_if_connect_udp | ( | struct mg_connection * | nc | ) |
References mg_connection::err, INVALID_SOCKET, and mg_connection::sock.
Referenced by mg_do_connect().
void mg_if_destroy_conn | ( | 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_recv_udp_cb | ( | struct mg_connection * | nc, |
void * | buf, | ||
int | len, | ||
union socket_address * | sa, | ||
size_t | sa_len | ||
) |
References DBG, mg_connection::flags, mg_connection::handler, mg_connection::listener, mg_add_conn(), mg_call(), mg_create_connection(), MG_EV_ACCEPT, MG_F_LISTENING, MG_F_UDP, MG_FREE, mg_if_recved(), mg_next(), mg_connection::mgr, nc, mg_connection::proto_data, mg_connection::proto_handler, mg_connection::recv_mbuf_limit, socket_address::sa, mg_connection::sa, mg_connection::sock, and mg_connection::user_data.
void mg_if_recved | ( | struct mg_connection * | nc, |
size_t | len | ||
) |
Referenced by mg_if_recv_tcp_cb(), and mg_if_recv_udp_cb().
void mg_if_sent_cb | ( | struct mg_connection * | nc, |
int | num_sent | ||
) |
References mg_connection::flags, mg_call(), MG_EV_SEND, and MG_F_CLOSE_IMMEDIATELY.
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_is_error | ( | int | n | ) |
References DBG.
Referenced by mg_if_connect_tcp().
MG_INTERNAL int mg_is_not_modified | ( | struct http_message * | hm, |
cs_stat_t * | st | ||
) |
References mg_get_http_header(), mg_parse_date_string(), mg_vcasecmp(), and mg_str::p.
Referenced by mg_send_http_file().
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_free | ( | struct mg_mgr * | m | ) |
References mg_mgr::active_connections, closesocket, mg_mgr::ctl, DBG, INVALID_SOCKET, mg_close_conn(), mg_ev_mgr_free(), mg_mgr_poll(), and mg_connection::next.
void mg_mgr_handle_conn | ( | struct mg_connection * | nc, |
int | fd_flags, | ||
time_t | now | ||
) |
References _MG_F_FD_CAN_READ, _MG_F_FD_CAN_WRITE, DBG, err, mg_connection::err, mg_connection::flags, mbuf::len, MG_F_CLOSE_IMMEDIATELY, MG_F_CONNECTING, MG_F_LISTENING, MG_F_UDP, mg_if_connect_cb(), mg_if_poll(), mg_connection::recv_mbuf, mg_connection::send_mbuf, and mg_connection::sock.
Referenced by mg_mgr_poll().
void mg_mgr_init | ( | struct mg_mgr * | m, |
void * | user_data | ||
) |
References mg_mgr::ctl, data, DBG, INVALID_SOCKET, mg_ev_mgr_init(), and mg_mgr::user_data.
time_t mg_mgr_poll | ( | struct mg_mgr * | mgr, |
int | milli | ||
) |
References _MG_F_FD_CAN_READ, _MG_F_FD_CAN_WRITE, _MG_F_FD_ERROR, mg_mgr::active_connections, mg_mgr::ctl, DBG, mg_connection::flags, INVALID_SOCKET, mbuf::len, mg_connection::listener, mg_add_to_set(), mg_close_conn(), MG_F_CLOSE_IMMEDIATELY, MG_F_CONNECTING, MG_F_SEND_AND_CLOSE, MG_F_UDP, MG_F_WANT_READ, MG_F_WANT_WRITE, mg_mgr_handle_conn(), nc, mg_connection::next, mg_connection::recv_mbuf, mg_connection::recv_mbuf_limit, mg_connection::send_mbuf, and mg_connection::sock.
Referenced by mg_mgr_free().
void mg_mqtt_connack | ( | struct mg_connection * | nc, |
uint8_t | return_code | ||
) |
References MG_MQTT_CMD_CONNACK, and mg_send().
void mg_mqtt_disconnect | ( | struct mg_connection * | nc | ) |
References MG_MQTT_CMD_DISCONNECT.
int mg_mqtt_next_subscribe_topic | ( | struct mg_mqtt_message * | msg, |
struct mg_str * | topic, | ||
uint8_t * | qos, | ||
int | pos | ||
) |
References if(), mg_str::len, mg_str::p, and mg_mqtt_message::payload.
void mg_mqtt_ping | ( | struct mg_connection * | nc | ) |
References MG_MQTT_CMD_PINGREQ.
void mg_mqtt_pong | ( | struct mg_connection * | nc | ) |
References MG_MQTT_CMD_PINGRESP.
void mg_mqtt_puback | ( | struct mg_connection * | nc, |
uint16_t | message_id | ||
) |
References MG_MQTT_CMD_PUBACK.
void mg_mqtt_pubcomp | ( | struct mg_connection * | nc, |
uint16_t | message_id | ||
) |
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 | ||
) |
References mbuf::len, MG_MQTT_CMD_PUBLISH, MG_MQTT_GET_QOS, mg_send(), and mg_connection::send_mbuf.
void mg_mqtt_pubrec | ( | struct mg_connection * | nc, |
uint16_t | message_id | ||
) |
References MG_MQTT_CMD_PUBREC.
void mg_mqtt_pubrel | ( | struct mg_connection * | nc, |
uint16_t | message_id | ||
) |
References MG_MQTT_CMD_PUBREL.
void mg_mqtt_suback | ( | struct mg_connection * | nc, |
uint8_t * | qoss, | ||
size_t | qoss_len, | ||
uint16_t | message_id | ||
) |
References MG_MQTT_CMD_SUBACK, MG_MQTT_QOS, and mg_send().
void mg_mqtt_subscribe | ( | struct mg_connection * | nc, |
const struct mg_mqtt_topic_expression * | topics, | ||
size_t | topics_len, | ||
uint16_t | message_id | ||
) |
References mbuf::len, MG_MQTT_CMD_SUBSCRIBE, MG_MQTT_QOS, mg_send(), and mg_connection::send_mbuf.
void mg_mqtt_unsuback | ( | struct mg_connection * | nc, |
uint16_t | message_id | ||
) |
References MG_MQTT_CMD_UNSUBACK.
void mg_mqtt_unsubscribe | ( | struct mg_connection * | nc, |
char ** | topics, | ||
size_t | topics_len, | ||
uint16_t | message_id | ||
) |
References mbuf::len, MG_MQTT_CMD_UNSUBSCRIBE, MG_MQTT_QOS, mg_send(), and mg_connection::send_mbuf.
int mg_ncasecmp | ( | const char * | s1, |
const char * | s2, | ||
size_t | len | ||
) |
Referenced by mg_casecmp(), mg_get_http_header(), mg_get_http_var(), mg_parse_multipart(), and mg_vcasecmp().
struct mg_connection* mg_next | ( | struct mg_mgr * | s, |
struct mg_connection * | conn | ||
) |
References mg_mgr::active_connections, and mg_connection::next.
Referenced by mg_if_recv_udp_cb().
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.
MG_INTERNAL int mg_parse_address | ( | const char * | str, |
union socket_address * | sa, | ||
int * | proto, | ||
char * | host, | ||
size_t | host_len | ||
) |
References mg_resolve_from_hosts_file(), socket_address::sin, and socket_address::sin6.
Referenced by mg_bind_opt(), and mg_connect_opt().
MG_INTERNAL time_t mg_parse_date_string | ( | const char * | datetime | ) |
References result.
Referenced by mg_is_not_modified().
int mg_parse_dns | ( | const char * | buf, |
int | len, | ||
struct mg_dns_message * | msg | ||
) |
int mg_parse_http | ( | const char * | s, |
int | n, | ||
struct http_message * | hm, | ||
int | is_req | ||
) |
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 ** | data, | ||
size_t * | data_len | ||
) |
References mg_str::len, mg_http_parse_header(), mg_ncasecmp(), and mg_str::p.
int mg_printf | ( | struct mg_connection * | conn, |
const char * | fmt, | ||
... | |||
) |
References mg_vprintf().
Referenced by mg_connect_http(), mg_send_head(), mg_send_http_file(), mg_send_response_line(), and mg_send_websocket_handshake().
void mg_printf_html_escape | ( | struct mg_connection * | nc, |
const char * | fmt, | ||
... | |||
) |
References mg_str::len, mg_avprintf(), MG_FREE, and mg_send().
void mg_printf_http_chunk | ( | struct mg_connection * | nc, |
const char * | fmt, | ||
... | |||
) |
References mg_str::len, mg_avprintf(), MG_FREE, and mg_send_http_chunk().
void mg_printf_websocket_frame | ( | struct mg_connection * | nc, |
int | op, | ||
const char * | fmt, | ||
... | |||
) |
References mg_avprintf(), MG_FREE, and mg_send_websocket_frame().
MG_INTERNAL void mg_remove_conn | ( | struct mg_connection * | c | ) |
References mg_mgr::active_connections, mg_ev_mgr_remove_conn(), mg_connection::mgr, mg_connection::next, and mg_connection::prev.
Referenced by mg_close_conn().
int mg_resolve | ( | const char * | host, |
char * | buf, | ||
size_t | n | ||
) |
int mg_resolve_async | ( | struct mg_mgr * | mgr, |
const char * | name, | ||
int | query, | ||
mg_resolve_callback_t | cb, | ||
void * | data | ||
) |
References mg_resolve_async_opt().
Referenced by mg_connect_opt().
int mg_resolve_async_opt | ( | struct mg_mgr * | mgr, |
const char * | name, | ||
int | query, | ||
mg_resolve_callback_t | cb, | ||
void * | data, | ||
struct mg_resolve_async_opts | opts | ||
) |
References data, DBG, free(), mg_resolve_async_opts::max_retries, MG_CALLOC, mg_connect(), mg_dns_server, mg_resolve_async_opts::nameserver_url, mg_resolve_async_opts::timeout, and mg_connection::user_data.
Referenced by mg_resolve_async().
int mg_resolve_from_hosts_file | ( | const char * | name, |
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, | ||
... | |||
) |
References mg_rpc_request::id, json_emit(), json_emit_va(), json_token::len, and json_token::ptr.
Referenced by mg_rpc_create_std_error().
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 * | buf, |
int | len, | ||
struct mg_rpc_request * | req, | ||
int | code | ||
) |
int mg_rpc_dispatch | ( | const char * | buf, |
int | len, | ||
char * | dst, | ||
int | dst_len, | ||
const char ** | methods, | ||
mg_rpc_handler_t * | handlers | ||
) |
References find_json_token(), mg_rpc_request::id, JSON_RPC_INVALID_REQUEST_ERROR, JSON_RPC_METHOD_NOT_FOUND_ERROR, JSON_RPC_PARSE_ERROR, JSON_RPC_SERVER_ERROR, JSON_STRING_INVALID, json_token::len, mg_rpc_request::message, mg_rpc_request::method, mg_rpc_create_std_error(), mg_rpc_request::params, parse_json(), and json_token::ptr.
int mg_rpc_parse_reply | ( | const char * | buf, |
int | len, | ||
struct json_token * | toks, | ||
int | max_toks, | ||
struct mg_rpc_reply * | rep, | ||
struct mg_rpc_error * | er | ||
) |
void mg_send | ( | struct mg_connection * | nc, |
const void * | buf, | ||
int | len | ||
) |
References mg_connection::flags, mg_mgr::hexdump_file, mg_connection::last_io_time, MG_EV_SEND, MG_F_UDP, mg_hexdump_connection(), mg_if_tcp_send(), mg_if_udp_send(), and mg_connection::mgr.
Referenced by mg_forward(), mg_mqtt_connack(), mg_mqtt_publish(), mg_mqtt_suback(), mg_mqtt_subscribe(), mg_mqtt_unsubscribe(), mg_printf_html_escape(), mg_send_dns_query(), mg_send_head(), mg_send_http_chunk(), mg_send_mqtt_handshake_opt(), mg_send_websocket_frame(), mg_send_websocket_framev(), and mg_vprintf().
void mg_send_dns_query | ( | struct mg_connection * | nc, |
const char * | name, | ||
int | query_type | ||
) |
References mbuf::buf, DBG, mg_connection::flags, mg_dns_message::flags, mg_dns_resource_record::kind, mbuf::len, mbuf_free(), mbuf_init(), mbuf_insert(), MG_CALLOC, mg_dns_encode_record(), mg_dns_insert_header(), MG_DNS_QUESTION, MG_F_UDP, MG_FREE, mg_send(), mg_dns_message::num_questions, mg_dns_message::questions, mg_dns_resource_record::rclass, mg_dns_resource_record::rtype, and mg_dns_message::transaction_id.
void mg_send_head | ( | struct mg_connection * | c, |
int | status_code, | ||
int64_t | content_length, | ||
const char * | extra_headers | ||
) |
References INT64_FMT, mg_printf(), mg_send(), and mg_send_response_line().
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_http_file | ( | struct mg_connection * | nc, |
char * | path, | ||
size_t | path_buf_len, | ||
struct http_message * | hm, | ||
struct mg_serve_http_opts * | opts | ||
) |
References mg_serve_http_opts::auth_domain, mg_serve_http_opts::cgi_file_pattern, mg_serve_http_opts::dav_auth_file, mg_serve_http_opts::dav_document_root, DBG, mg_serve_http_opts::enable_directory_listing, find_index_file(), mg_connection::flags, mg_serve_http_opts::global_auth_file, mg_serve_http_opts::index_files, mg_serve_http_opts::ip_acl, mg_str::len, http_message::method, mg_check_ip_acl(), MG_F_CLOSE_IMMEDIATELY, mg_is_not_modified(), mg_match_prefix(), mg_printf(), mg_stat(), mg_vcmp(), mg_str::p, mg_serve_http_opts::per_directory_auth_file, mg_connection::sa, socket_address::sin, and http_message::uri.
Referenced by mg_serve_http().
void mg_send_mqtt_handshake | ( | struct mg_connection * | nc, |
const char * | client_id | ||
) |
References mg_send_mqtt_handshake_opt().
void mg_send_mqtt_handshake_opt | ( | struct mg_connection * | nc, |
const char * | client_id, | ||
struct mg_send_mqtt_handshake_opts | opts | ||
) |
References mg_send_mqtt_handshake_opts::flags, mg_send_mqtt_handshake_opts::keep_alive, MG_MQTT_CMD_CONNECT, and mg_send().
Referenced by mg_send_mqtt_handshake().
void mg_send_response_line | ( | struct mg_connection * | nc, |
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, | ||
const void * | data, | ||
size_t | len | ||
) |
References mg_connection::flags, MG_F_SEND_AND_CLOSE, mg_send(), mg_connection::send_mbuf, and WEBSOCKET_OP_CLOSE.
Referenced by event_cb(), and mg_printf_websocket_frame().
void mg_send_websocket_framev | ( | struct mg_connection * | nc, |
int | op, | ||
const struct mg_str * | strv, | ||
int | strvcnt | ||
) |
References mg_connection::flags, mg_str::len, MG_F_SEND_AND_CLOSE, mg_send(), mg_connection::send_mbuf, and WEBSOCKET_OP_CLOSE.
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_serve_http | ( | struct mg_connection * | nc, |
struct http_message * | hm, | ||
struct mg_serve_http_opts | opts | ||
) |
References mg_serve_http_opts::cgi_file_pattern, mg_serve_http_opts::document_root, mg_serve_http_opts::enable_directory_listing, mg_connection::flags, mg_serve_http_opts::index_files, MG_F_SEND_AND_CLOSE, mg_get_http_header(), MG_MAX_PATH, mg_send_http_file(), mg_vcmp(), mg_serve_http_opts::per_directory_auth_file, http_message::proto, and mg_serve_http_opts::ssi_pattern.
void mg_set_close_on_exec | ( | sock_t | sock | ) |
Referenced by mg_socketpair().
void mg_set_non_blocking_mode | ( | sock_t | sock | ) |
Referenced by mg_if_connect_tcp().
void mg_set_protocol_dns | ( | struct mg_connection * | nc | ) |
References mg_connection::proto_handler.
void mg_set_protocol_http_websocket | ( | struct mg_connection * | nc | ) |
References http_handler(), and mg_connection::proto_handler.
Referenced by mg_connect_http().
void mg_set_protocol_mqtt | ( | struct mg_connection * | nc | ) |
References mg_connection::proto_handler.
const char* mg_skip | ( | const char * | s, |
const char * | end, | ||
const char * | delims, | ||
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 | ||
) |
References if(), mg_str::len, MG_SOCK_STRINGIFY_IP, MG_SOCK_STRINGIFY_PORT, socket_address::sa, socket_address::sin, and socket_address::sin6.
Referenced by mg_sock_to_str().
void mg_sock_to_str | ( | sock_t | sock, |
char * | buf, | ||
size_t | len, | ||
int | flags | ||
) |
References mg_sock_addr_to_str(), MG_SOCK_STRINGIFY_REMOTE, and socket_address::sa.
Referenced by mg_hexdump_connection().
int mg_socketpair | ( | sock_t | sp[2], |
int | sock_type | ||
) |
References closesocket, INVALID_SOCKET, mg_set_close_on_exec(), socket_address::sa, and socket_address::sin.
Referenced by mg_ev_mgr_init().
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 * | str1, |
const char * | str2 | ||
) |
References mg_str::len, mg_ncasecmp(), and mg_str::p.
Referenced by http_handler(), mg_is_not_modified(), and mg_parse_http().
int mg_vcmp | ( | const struct mg_str * | str1, |
const char * | str2 | ||
) |
References mg_str::len, and mg_str::p.
Referenced by mg_send_http_file(), and mg_serve_http().
int mg_vprintf | ( | struct mg_connection * | nc, |
const char * | fmt, | ||
va_list | ap | ||
) |
References mg_avprintf(), MG_FREE, mg_send(), and MG_VPRINTF_BUFFER_SIZE.
Referenced by mg_printf().
int parse_json | ( | const char * | s, |
int | s_len, | ||
struct json_token * | arr, | ||
int | arr_len | ||
) |
References TRY.
Referenced by mg_rpc_dispatch(), and mg_rpc_parse_reply().
struct json_token* parse_json2 | ( | const char * | s, |
int | s_len | ||
) |
References FROZEN_FREE.
size_t strnlen | ( | const char * | s, |
size_t | maxlen | ||
) |
Referenced by c_vsnprintf().
size_t ext_len |
const char* extension |
MG_INTERNAL char mg_dns_server[256] |
Referenced by mg_resolve_async_opt().
const char* mime_type |
enum cs_log_level s_cs_log_level |
void*(* test_calloc)(size_t, size_t) |
void*(* test_malloc)(size_t) |