1
0
mirror of https://github.com/lammertb/libhttp.git synced 2025-08-17 22:21:06 +03:00

API CHANGE: using struct mg_callbacks

This commit is contained in:
Sergey Lyubka
2013-02-01 16:48:30 +00:00
parent 62162ff3e4
commit ee55d38b55
10 changed files with 282 additions and 384 deletions

17
main.c
View File

@@ -266,17 +266,14 @@ static void init_server_name(void) {
mg_version());
}
static void *mongoose_callback(enum mg_event ev, struct mg_connection *conn) {
if (ev == MG_EVENT_LOG) {
printf("%s\n", (const char *) mg_get_request_info(conn)->ev_data);
}
// Returning NULL marks request as not handled, signalling mongoose to
// proceed with handling it.
return NULL;
static int log_message(const struct mg_connection *conn, const char *message) {
(void) conn;
printf("%s\n", message);
return 0;
}
static void start_mongoose(int argc, char *argv[]) {
struct mg_callbacks callbacks;
char *options[MAX_OPTIONS];
int i;
@@ -302,7 +299,9 @@ static void start_mongoose(int argc, char *argv[]) {
signal(SIGINT, signal_handler);
/* Start Mongoose */
ctx = mg_start(&mongoose_callback, NULL, (const char **) options);
memset(&callbacks, 0, sizeof(callbacks));
callbacks.log_message = &log_message;
ctx = mg_start(&callbacks, NULL, (const char **) options);
for (i = 0; options[i] != NULL; i++) {
free(options[i]);
}