Started to restore single callback function

This commit is contained in:
Sergey Lyubka 2013-09-26 13:25:51 +01:00
parent 6d2a76b609
commit 079c99c47f
2 changed files with 20 additions and 0 deletions

View File

@ -491,6 +491,7 @@ struct mg_context {
SSL_CTX *ssl_ctx; // SSL context
char *config[NUM_OPTIONS]; // Mongoose configuration parameters
struct mg_callbacks callbacks; // User-defined callback function
mg_callback_t user_callback; // User-defined callback function
void *user_data; // User-defined data
struct socket *listening_sockets;
@ -540,6 +541,14 @@ const char **mg_get_valid_option_names(void) {
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) {
#ifdef _WIN32
wchar_t wbuf[PATH_MAX], wmode[20];

View File

@ -49,6 +49,17 @@ struct mg_request_info {
} 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 {
int (*begin_request)(struct mg_connection *);