Skip to content
Snippets Groups Projects
Commit 079c99c4 authored by Sergey Lyubka's avatar Sergey Lyubka
Browse files

Started to restore single callback function

parent 6d2a76b6
No related branches found
No related tags found
No related merge requests found
...@@ -491,6 +491,7 @@ struct mg_context { ...@@ -491,6 +491,7 @@ struct mg_context {
SSL_CTX *ssl_ctx; // SSL context SSL_CTX *ssl_ctx; // SSL context
char *config[NUM_OPTIONS]; // Mongoose configuration parameters char *config[NUM_OPTIONS]; // Mongoose configuration parameters
struct mg_callbacks callbacks; // User-defined callback function struct mg_callbacks callbacks; // User-defined callback function
mg_callback_t user_callback; // User-defined callback function
void *user_data; // User-defined data void *user_data; // User-defined data
struct socket *listening_sockets; struct socket *listening_sockets;
...@@ -540,6 +541,14 @@ const char **mg_get_valid_option_names(void) { ...@@ -540,6 +541,14 @@ const char **mg_get_valid_option_names(void) {
return config_options; return config_options;
} }
static int call_user(enum mg_event ev, struct mg_connection *conn, void *p) {
if (conn != NULL && conn->ctx != NULL) {
conn->request_info.user_data = conn->ctx->user_data;
}
return conn == NULL || conn->ctx == NULL || conn->ctx->user_callback == NULL ?
0 : conn->ctx->user_callback(ev, conn, p);
}
static FILE *mg_fopen(const char *path, const char *mode) { static FILE *mg_fopen(const char *path, const char *mode) {
#ifdef _WIN32 #ifdef _WIN32
wchar_t wbuf[PATH_MAX], wmode[20]; wchar_t wbuf[PATH_MAX], wmode[20];
......
...@@ -49,6 +49,17 @@ struct mg_request_info { ...@@ -49,6 +49,17 @@ struct mg_request_info {
} http_headers[64]; // Maximum 64 headers } http_headers[64]; // Maximum 64 headers
}; };
enum mg_event {
MG_REQUEST_BEGIN,
MG_REQUEST_END,
MG_HTTP_ERROR,
MG_EVENT_LOG,
MG_THREAD_BEGIN,
MG_THREAD_END
};
typedef int (*mg_callback_t)(enum mg_event event,
struct mg_connection *conn,
void *data);
struct mg_callbacks { struct mg_callbacks {
int (*begin_request)(struct mg_connection *); int (*begin_request)(struct mg_connection *);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment