diff options
author | Andreas Baumann <mail@andreasbaumann.cc> | 2015-04-09 19:33:53 +0200 |
---|---|---|
committer | Andreas Baumann <mail@andreasbaumann.cc> | 2015-04-09 19:33:53 +0200 |
commit | 28a64040520aa9e043306a9e8af0f615227f2eb0 (patch) | |
tree | 2ac149b924065eb3dc42621362018494f01fc15e /src/webserver.c | |
parent | abc3d8fec7e21f01890f2f862ae6fc799e8e9df6 (diff) | |
download | biruda-28a64040520aa9e043306a9e8af0f615227f2eb0.tar.gz biruda-28a64040520aa9e043306a9e8af0f615227f2eb0.tar.bz2 |
fixed for older libmicrohttpd response function
Diffstat (limited to 'src/webserver.c')
-rw-r--r-- | src/webserver.c | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/src/webserver.c b/src/webserver.c index 611cc42..4c6fedf 100644 --- a/src/webserver.c +++ b/src/webserver.c @@ -14,6 +14,17 @@ static struct MHD_Daemon *d; +static struct MHD_Response *wrap_response( size_t size, void *buffer, enum MHD_ResponseMemoryMode mode) +{ +#if MHD_VERSION >= 0x00090500 + return MHD_create_response_from_buffer( size, buffer, mode ); +#else + return MHD_create_response_from_data( size, buffer, + ( mode | MHD_RESPMEM_MUST_FREE ) == MHD_RESPMEM_MUST_FREE, + ( mode | MHD_RESPMEM_MUST_COPY ) == MHD_RESPMEM_MUST_COPY ); +#endif +} + static int handle_request( void *cls, struct MHD_Connection *connection, const char *url, const char *method, const char *version, const char *upload_data, size_t *upload_data_size, void **ptr ) @@ -85,7 +96,7 @@ static int handle_request( void *cls, struct MHD_Connection *connection, snprintf( biruda_msg, sizeof( biruda_msg ), "Welcome to biruda! Please state your wish..\n" ); } - response = MHD_create_response_from_buffer( strlen( biruda_msg ), + response = wrap_response( strlen( biruda_msg ), (void *)biruda_msg, MHD_RESPMEM_MUST_COPY ); ret = MHD_queue_response( connection, MHD_HTTP_OK, response ); MHD_destroy_response( response ); @@ -121,7 +132,7 @@ static int handle_request( void *cls, struct MHD_Connection *connection, snprintf( biruda_msg, sizeof( biruda_msg ), "Queued start worker request\n" ); } - response = MHD_create_response_from_buffer( strlen( biruda_msg ), + response = wrap_response( strlen( biruda_msg ), (void *)biruda_msg, MHD_RESPMEM_MUST_COPY ); ret = MHD_queue_response( connection, ( res == 0 ) ? MHD_HTTP_OK : MHD_HTTP_INTERNAL_SERVER_ERROR, response ); MHD_destroy_response( response ); @@ -142,7 +153,7 @@ static int handle_request( void *cls, struct MHD_Connection *connection, snprintf( biruda_msg, sizeof( biruda_msg ), "Queued stop worker request\n" ); } - response = MHD_create_response_from_buffer( strlen( biruda_msg ), + response = wrap_response( strlen( biruda_msg ), (void *)biruda_msg, MHD_RESPMEM_MUST_COPY ); ret = MHD_queue_response( connection, ( res == 0 ) ? MHD_HTTP_OK : MHD_HTTP_INTERNAL_SERVER_ERROR, response ); MHD_destroy_response( response ); |