23 #ifndef CIVETWEB_HEADER_INCLUDED 24 #define CIVETWEB_HEADER_INCLUDED 26 #define CIVETWEB_VERSION "1.10" 27 #define CIVETWEB_VERSION_MAJOR (1) 28 #define CIVETWEB_VERSION_MINOR (10) 29 #define CIVETWEB_VERSION_PATCH (0) 30 #define CIVETWEB_VERSION_RELEASED 34 #if defined(CIVETWEB_DLL_EXPORTS) 35 #define CIVETWEB_API __declspec(dllexport) 36 #elif defined(CIVETWEB_DLL_IMPORTS) 37 #define CIVETWEB_API __declspec(dllimport) 42 #define CIVETWEB_API __attribute__((visibility("default"))) 80 #define MG_MAX_HEADERS (64) 96 #if defined(MG_LEGACY_INTERFACE) 104 char remote_addr[48];
106 #if defined(MG_LEGACY_INTERFACE) 181 int (*begin_request)(
struct mg_connection *);
184 void (*end_request)(
const struct mg_connection *,
int reply_status_code);
188 int (*log_message)(
const struct mg_connection *,
const char *message);
192 int (*
log_access)(
const struct mg_connection *,
const char *message);
201 int (*init_ssl)(
void *ssl_context,
void *user_data);
203 #if defined(MG_LEGACY_INTERFACE) 209 int (*websocket_connect)(
const struct mg_connection *);
214 void (*websocket_ready)(
struct mg_connection *);
225 int (*websocket_data)(
struct mg_connection *,
246 void (*connection_close)(
const struct mg_connection *);
248 #if defined(MG_USE_OPEN_FILE) 270 const char *(*open_file)(
const struct mg_connection *,
279 void (*init_lua)(
const struct mg_connection *,
void *lua_context);
281 #if defined(MG_LEGACY_INTERFACE) 287 void (*upload)(
struct mg_connection *,
const char *file_name);
297 int (*http_error)(
struct mg_connection *,
int status);
303 void (*init_context)(
const struct mg_context *ctx);
313 void (*init_thread)(
const struct mg_context *ctx,
int thread_type);
318 void (*exit_context)(
const struct mg_context *ctx);
364 const char **configuration_options);
479 struct mg_context *ctx,
556 #if defined(MG_LEGACY_INTERFACE) 562 CIVETWEB_API const char **mg_get_valid_option_names(
void);
626 #if defined(MG_LEGACY_INTERFACE) 629 mg_get_ports(
const struct mg_context *ctx,
size_t size,
int *ports,
int *ssl);
654 const char *password);
729 #if defined(MG_LEGACY_INTERFACE) 730 #define mg_lock mg_lock_connection 731 #define mg_unlock mg_unlock_connection 763 #undef PRINTF_FORMAT_STRING 764 #if defined(_MSC_VER) && _MSC_VER >= 1400 766 #if defined(_MSC_VER) && _MSC_VER > 1400 767 #define PRINTF_FORMAT_STRING(s) _Printf_format_string_ s 769 #define PRINTF_FORMAT_STRING(s) __format_string s 772 #define PRINTF_FORMAT_STRING(s) s 776 #define PRINTF_ARGS(x, y) __attribute__((format(printf, x, y))) 778 #define PRINTF_ARGS(x, y) 794 unsigned int chunk_len);
844 const
char *filename);
872 const
char *mime_type,
873 const
char *additional_headers);
924 const
char *var_name,
954 const
char *var_name,
974 const
char *var_name,
999 size_t error_buffer_size,
1001 ...) PRINTF_ARGS(6, 7);
1008 #if defined(MG_LEGACY_INTERFACE) 1014 const char *destination_dir);
1040 int (*field_found)(
const char *key,
1041 const char *filename,
1057 int (*field_get)(
const char *key,
1078 int (*field_store)(
const char *path,
long long file_size,
void *user_data);
1126 typedef void *(*mg_thread_func_t)(
void *);
1154 int is_form_url_encoded);
1181 ...) PRINTF_ARGS(2, 3);
1212 size_t error_buffer_size,
1236 size_t error_buffer_size);
1251 size_t error_buffer_size);
1339 #ifdef MG_EXPERIMENTAL_INTERFACES 1356 CIVETWEB_API int mg_get_connection_info(
const struct mg_context *ctx,
CIVETWEB_API struct mg_context * mg_start(const struct mg_callbacks *callbacks, void *user_data, const char **configuration_options)
CIVETWEB_API void CIVETWEB_API int mg_send_digest_access_authentication_request(struct mg_connection *conn, const char *realm)
CIVETWEB_API int mg_strncasecmp(const char *s1, const char *s2, size_t len)
CIVETWEB_API unsigned mg_init_library(unsigned features)
#define PRINTF_ARGS(x, y)
CIVETWEB_API void mg_unlock_connection(struct mg_connection *conn)
CIVETWEB_API void mg_set_user_connection_data(struct mg_connection *conn, void *data)
CIVETWEB_API void * mg_get_user_data(const struct mg_context *ctx)
CIVETWEB_API struct mg_connection * mg_connect_client(const char *host, int port, int use_ssl, char *error_buffer, size_t error_buffer_size)
CIVETWEB_API void mg_set_websocket_handler(struct mg_context *ctx, const char *uri, mg_websocket_connect_handler connect_handler, mg_websocket_ready_handler ready_handler, mg_websocket_data_handler data_handler, mg_websocket_close_handler close_handler, void *cbdata)
CIVETWEB_API struct mg_connection * mg_download(const char *host, int port, int use_ssl, char *error_buffer, size_t error_buffer_size, PRINTF_FORMAT_STRING(const char *request_fmt),...) PRINTF_ARGS(6
CIVETWEB_API struct mg_connection * mg_connect_websocket_client(const char *host, int port, int use_ssl, char *error_buffer, size_t error_buffer_size, const char *path, const char *origin, mg_websocket_data_handler data_func, mg_websocket_close_handler close_func, void *user_data)
CIVETWEB_API int mg_printf(struct mg_connection *, PRINTF_FORMAT_STRING(const char *fmt),...) PRINTF_ARGS(2
CIVETWEB_API struct mg_connection CIVETWEB_API void mg_close_connection(struct mg_connection *conn)
CIVETWEB_API const char * mg_get_option(const struct mg_context *ctx, const char *name)
CIVETWEB_API void mg_lock_context(struct mg_context *ctx)
CIVETWEB_API struct mg_connection * mg_connect_client_secure(const struct mg_client_options *client_options, char *error_buffer, size_t error_buffer_size)
CIVETWEB_API int mg_check_digest_access_authentication(struct mg_connection *conn, const char *realm, const char *filename)
CIVETWEB_API void mg_unlock_context(struct mg_context *ctx)
CIVETWEB_API const char * mg_get_header(const struct mg_connection *, const char *name)
int(* mg_authorization_handler)(struct mg_connection *conn, void *cbdata)
CIVETWEB_API long long mg_store_body(struct mg_connection *conn, const char *path)
CIVETWEB_API const char * mg_get_response_code_text(const struct mg_connection *conn, int response_code)
CIVETWEB_API void mg_send_mime_file(struct mg_connection *conn, const char *path, const char *mime_type)
const char * default_value
#define PRINTF_FORMAT_STRING(s)
const char * request_method
CIVETWEB_API unsigned mg_check_feature(unsigned feature)
CIVETWEB_API const char * mg_get_builtin_mime_type(const char *file_name)
static void init_connection(struct mg_connection *conn)
CIVETWEB_API int mg_get_context_info(const struct mg_context *ctx, char *buffer, int buflen)
int(* mg_websocket_data_handler)(struct mg_connection *, int, char *, size_t, void *)
const char * acceptedWebSocketSubprotocol
void(* mg_websocket_close_handler)(const struct mg_connection *, void *)
CIVETWEB_API void mg_send_http_error(struct mg_connection *conn, int status_code, PRINTF_FORMAT_STRING(const char *fmt),...) PRINTF_ARGS(3
CIVETWEB_API void mg_cry(const struct mg_connection *conn, PRINTF_FORMAT_STRING(const char *fmt),...) PRINTF_ARGS(2
CIVETWEB_API void CIVETWEB_API int mg_strcasecmp(const char *s1, const char *s2)
CIVETWEB_API void mg_set_request_handler(struct mg_context *ctx, const char *uri, mg_request_handler handler, void *cbdata)
CIVETWEB_API void mg_lock_connection(struct mg_connection *conn)
CIVETWEB_API int mg_get_cookie(const char *cookie, const char *var_name, char *buf, size_t buf_len)
CIVETWEB_API int mg_write(struct mg_connection *, const void *buf, size_t len)
CIVETWEB_API int mg_url_encode(const char *src, char *dst, size_t dst_len)
CIVETWEB_API int mg_get_server_ports(const struct mg_context *ctx, int size, struct mg_server_ports *ports)
CIVETWEB_API void mg_send_file(struct mg_connection *conn, const char *path)
const char * http_version
CIVETWEB_API int mg_get_response(struct mg_connection *conn, char *ebuf, size_t ebuf_len, int timeout)
CIVETWEB_API void mg_send_mime_file2(struct mg_connection *conn, const char *path, const char *mime_type, const char *additional_headers)
int(* mg_request_handler)(struct mg_connection *conn, void *cbdata)
CIVETWEB_API const struct mg_request_info * mg_get_request_info(const struct mg_connection *)
CIVETWEB_API int mg_start_thread(mg_thread_func_t f, void *p)
CIVETWEB_API int mg_get_system_info(char *buffer, int buflen)
CIVETWEB_API int mg_websocket_write(struct mg_connection *conn, int opcode, const char *data, size_t data_len)
struct mg_client_cert * client_cert
CIVETWEB_API const struct mg_response_info * mg_get_response_info(const struct mg_connection *)
CIVETWEB_API int CIVETWEB_API int mg_send_chunk(struct mg_connection *conn, const char *chunk, unsigned int chunk_len)
int(* mg_websocket_connect_handler)(const struct mg_connection *, void *)
CIVETWEB_API int mg_url_decode(const char *src, int src_len, char *dst, int dst_len, int is_form_url_encoded)
CIVETWEB_API void * mg_get_user_connection_data(const struct mg_connection *conn)
CIVETWEB_API void mg_set_websocket_handler_with_subprotocols(struct mg_context *ctx, const char *uri, struct mg_websocket_subprotocols *subprotocols, mg_websocket_connect_handler connect_handler, mg_websocket_ready_handler ready_handler, mg_websocket_data_handler data_handler, mg_websocket_close_handler close_handler, void *cbdata)
CIVETWEB_API int mg_get_var2(const char *data, size_t data_len, const char *var_name, char *dst, size_t dst_len, size_t occurrence)
CIVETWEB_API char * mg_md5(char buf[33],...)
CIVETWEB_API struct mg_context * mg_get_context(const struct mg_connection *conn)
CIVETWEB_API int mg_read(struct mg_connection *, void *buf, size_t len)
typedef void((*Func_t)())
void(* mg_websocket_ready_handler)(struct mg_connection *, void *)
CIVETWEB_API unsigned mg_exit_library(void)
void *(* mg_thread_func_t)(void *)
CIVETWEB_API int mg_handle_form_request(struct mg_connection *conn, struct mg_form_data_handler *fdh)
CIVETWEB_API int mg_get_var(const char *data, size_t data_len, const char *var_name, char *dst, size_t dst_len)
CIVETWEB_API int mg_websocket_client_write(struct mg_connection *conn, int opcode, const char *data, size_t data_len)
const char * query_string
CIVETWEB_API void mg_set_auth_handler(struct mg_context *ctx, const char *uri, mg_authorization_handler handler, void *cbdata)
CIVETWEB_API int mg_modify_passwords_file(const char *passwords_file_name, const char *realm, const char *user, const char *password)
CIVETWEB_API const char * mg_version(void)
CIVETWEB_API int mg_get_request_link(const struct mg_connection *conn, char *buf, size_t buflen)
CIVETWEB_API const struct mg_option * mg_get_valid_options(void)
const char * http_version
static void log_access(const struct mg_connection *conn)
CIVETWEB_API void mg_stop(struct mg_context *)