From 890f8e992bf0afeb51c4df8d8503c7d06fa1b6d5 Mon Sep 17 00:00:00 2001 From: Gabriel Gritsch Date: Sat, 15 Feb 2014 16:20:25 +0800 Subject: [PATCH] add const http write helper Since libwebsocket_write doesn't change the source buffer in HTTP protocol, we can have a little helper to hide the harmless cast --- lib/libwebsockets.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/libwebsockets.h b/lib/libwebsockets.h index 1408ef53..676d50e7 100644 --- a/lib/libwebsockets.h +++ b/lib/libwebsockets.h @@ -1009,6 +1009,15 @@ LWS_VISIBLE LWS_EXTERN int libwebsocket_write(struct libwebsocket *wsi, unsigned char *buf, size_t len, enum libwebsocket_write_protocol protocol); +/* helper for case where buffer may be const */ +static inline int +libwebsocket_write_http(struct libwebsocket *wsi, + const unsigned char *buf, size_t len) +{ + return libwebsocket_write(wsi, (unsigned char *)buf, len, + LWS_WRITE_HTTP); +} + LWS_VISIBLE LWS_EXTERN int libwebsockets_serve_http_file(struct libwebsocket_context *context, struct libwebsocket *wsi, const char *file,