summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Baumann <mail@andreasbaumann.cc>2015-04-09 19:44:54 +0200
committerAndreas Baumann <mail@andreasbaumann.cc>2015-04-09 19:44:54 +0200
commitf27a9f38bb5de90a4d4ce240a8322c1e937820b8 (patch)
treec6683ce782f29466ecd6eece5c5bcda537fb4d06
parent28a64040520aa9e043306a9e8af0f615227f2eb0 (diff)
downloadbiruda-f27a9f38bb5de90a4d4ce240a8322c1e937820b8.tar.gz
biruda-f27a9f38bb5de90a4d4ce240a8322c1e937820b8.tar.bz2
better solution for MHD_create_response_from_buffer
-rw-r--r--src/webserver.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/src/webserver.c b/src/webserver.c
index 4c6fedf..81ec523 100644
--- a/src/webserver.c
+++ b/src/webserver.c
@@ -14,16 +14,23 @@
static struct MHD_Daemon *d;
+#if MHD_VERSION < 0x00090500
+enum MHD_ResponseMemoryMode {
+ MHD_RESPMEM_PERSISTENT,
+ MHD_RESPMEM_MUST_FREE,
+ MHD_RESPMEM_MUST_COPY
+};
+
+#define MHD_create_response_from_buffer wrap_response
+
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
}
+
+#endif
static int handle_request( void *cls, struct MHD_Connection *connection,
const char *url, const char *method, const char *version,
@@ -96,7 +103,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 = wrap_response( strlen( biruda_msg ),
+ response = MHD_create_response_from_buffer( strlen( biruda_msg ),
(void *)biruda_msg, MHD_RESPMEM_MUST_COPY );
ret = MHD_queue_response( connection, MHD_HTTP_OK, response );
MHD_destroy_response( response );
@@ -132,7 +139,7 @@ static int handle_request( void *cls, struct MHD_Connection *connection,
snprintf( biruda_msg, sizeof( biruda_msg ), "Queued start worker request\n" );
}
- response = wrap_response( strlen( biruda_msg ),
+ response = MHD_create_response_from_buffer( 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 );
@@ -153,7 +160,7 @@ static int handle_request( void *cls, struct MHD_Connection *connection,
snprintf( biruda_msg, sizeof( biruda_msg ), "Queued stop worker request\n" );
}
- response = wrap_response( strlen( biruda_msg ),
+ response = MHD_create_response_from_buffer( 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 );