summaryrefslogtreecommitdiff
path: root/src/webserver.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/webserver.c')
-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 );