mirror of
https://github.com/warmcat/libwebsockets.git
synced 2025-03-16 00:00:07 +01:00

The user protocols struct has not been const until now. This has been painful for a while because the semantics of the protocols struct look like it's going to be treated as const. At context creation, the protocols struct has been getting marked with the context, and three apis exploited that to only need to be passed a pointer to a protocol to get access to the context. This patch removes the two writeable members in the context (these were never directly used by user code), changes all pointers to protocols to be const, and adds an explicit first argument to the three affected apis so they can have access to context. The three affected apis are these LWS_VISIBLE LWS_EXTERN int -lws_callback_on_writable_all_protocol(const struct lws_protocols *protocol); +lws_callback_on_writable_all_protocol(const struct lws_context *context, + const struct lws_protocols *protocol); LWS_VISIBLE LWS_EXTERN int -lws_callback_all_protocol(const struct lws_protocols *protocol, int reason); +lws_callback_all_protocol(struct lws_context *context, + const struct lws_protocols *protocol, int reason); LWS_VISIBLE LWS_EXTERN void -lws_rx_flow_allow_all_protocol(const struct lws_protocols *protocol); +lws_rx_flow_allow_all_protocol(const struct lws_context *context, + const struct lws_protocols *protocol); unfortunately the original apis can no longer be emulated and users of them must update. Signed-off-by: Andy Green <andy.green@linaro.org>
25 lines
619 B
C
25 lines
619 B
C
|
|
#include <zlib.h>
|
|
|
|
#define DEFLATE_FRAME_COMPRESSION_LEVEL_SERVER 1
|
|
#define DEFLATE_FRAME_COMPRESSION_LEVEL_CLIENT Z_DEFAULT_COMPRESSION
|
|
|
|
struct lws_ext_deflate_frame_conn {
|
|
z_stream zs_in;
|
|
z_stream zs_out;
|
|
size_t buf_pre_used;
|
|
size_t buf_pre_length;
|
|
size_t buf_in_length;
|
|
size_t buf_out_length;
|
|
int compressed_out;
|
|
unsigned char *buf_pre;
|
|
unsigned char *buf_in;
|
|
unsigned char *buf_out;
|
|
};
|
|
|
|
extern int lws_extension_callback_deflate_frame(
|
|
struct lws_context *context,
|
|
const struct lws_extension *ext,
|
|
struct lws *wsi,
|
|
enum lws_extension_callback_reasons reason,
|
|
void *user, void *in, size_t len);
|