mirror of
https://github.com/cesanta/mongoose.git
synced 2024-12-28 15:40:23 +08:00
Started to restore single callback function
This commit is contained in:
parent
6d2a76b609
commit
079c99c47f
@ -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) {
|
|||||||
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];
|
||||||
|
11
mongoose.h
11
mongoose.h
@ -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 *);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user