mirror of
https://github.com/cesanta/mongoose.git
synced 2026-11-17 19:30:36 +00:00
Moving to event-based API, temporary breaking tests
This commit is contained in:
1 parent
de35a353d4
commit
2ac970fa16
3 files changed
+109
-136
No files matched your search
+14
-10
@@ -55,26 +55,31 @@ struct mg_connection {
|
||||
int wsbits; // First byte of the websocket frame
|
||||
void *server_param; // Parameter passed to mg_add_uri_handler()
|
||||
void *connection_param; // Placeholder for connection-specific data
|
||||
void *callback_param; // Used by mg_iterate_over_connections()
|
||||
};
|
||||
|
||||
struct mg_server; // Opaque structure describing server instance
|
||||
typedef int (*mg_handler_t)(struct mg_connection *);
|
||||
enum mg_result { MG_FALSE, MG_TRUE };
|
||||
enum mg_event {
|
||||
MG_POLL, // Callback return value is ignored
|
||||
MG_AUTH, // If callback returns MG_FALSE, authentication fails
|
||||
MG_REQ_BEGIN, // If callback returns MG_FALSE, Mongoose continues with req
|
||||
MG_REQ_END, // Callback return value is ignored
|
||||
MG_CLOSE, // Connection is closed
|
||||
MG_CONNECT, // If callback returns MG_FALSE, connect fails
|
||||
MG_HTTP_ERROR // If callback returns MG_FALSE, Mongoose continues with err
|
||||
};
|
||||
typedef int (*mg_handler_t)(struct mg_connection *, enum mg_event);
|
||||
|
||||
// Server management functions
|
||||
struct mg_server *mg_create_server(void *server_param);
|
||||
struct mg_server *mg_create_server(void *server_param, mg_handler_t handler);
|
||||
void mg_destroy_server(struct mg_server **);
|
||||
const char *mg_set_option(struct mg_server *, const char *opt, const char *val);
|
||||
int mg_poll_server(struct mg_server *, int milliseconds);
|
||||
void mg_set_request_handler(struct mg_server *, mg_handler_t);
|
||||
void mg_set_http_close_handler(struct mg_server *, mg_handler_t);
|
||||
void mg_set_http_error_handler(struct mg_server *, mg_handler_t);
|
||||
void mg_set_auth_handler(struct mg_server *, mg_handler_t);
|
||||
const char **mg_get_valid_option_names(void);
|
||||
const char *mg_get_option(const struct mg_server *server, const char *name);
|
||||
void mg_set_listening_socket(struct mg_server *, int sock);
|
||||
int mg_get_listening_socket(struct mg_server *);
|
||||
void mg_iterate_over_connections(struct mg_server *, mg_handler_t, void *);
|
||||
void mg_iterate_over_connections(struct mg_server *, mg_handler_t);
|
||||
|
||||
// Connection management functions
|
||||
void mg_send_status(struct mg_connection *, int status_code);
|
||||
@@ -115,8 +120,7 @@ enum {
|
||||
MG_CONNECT_SUCCESS, MG_CONNECT_FAILURE,
|
||||
MG_DOWNLOAD_SUCCESS, MG_DOWNLOAD_FAILURE
|
||||
};
|
||||
int mg_connect(struct mg_server *, const char *host, int port, int use_ssl,
|
||||
mg_handler_t handler, void *param);
|
||||
struct mg_connection *mg_connect(struct mg_server *, const char *, int, int);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user