[Libwebsockets] RFC: more public api normalization before 1.6

Andy Green andy at warmcat.com
Tue Dec 15 14:44:31 CET 2015


Hi -

I just pushed a patch that removed many internal api context parameter 
passings, since we gave every wsi a context pointer now.  It doesn't 
affect anything since everything internal to the library.

https://github.com/warmcat/libwebsockets/commit/6b5de70f4fb1eadac6730f3b4ecfe156bd38567a

However there are 11 public APIs that could get the same treatment.  I'm 
not sure if the context parameter to the user callback could also go, 
since maybe sometimes wsi is NULL there, but possibly that too.

Basically all these guys can lose the context parameter now:

LWS_VISIBLE LWS_EXTERN int
lws_add_http_header_by_name(struct lws_context *context,
			    struct lws *wsi,
			    const unsigned char *name,
			    const unsigned char *value,
			    int length,
			    unsigned char **p,
			    unsigned char *end);
LWS_VISIBLE LWS_EXTERN int
lws_finalize_http_header(struct lws_context *context,
			 struct lws *wsi,
			 unsigned char **p,
			 unsigned char *end);
LWS_VISIBLE LWS_EXTERN int
lws_add_http_header_by_token(struct lws_context *context,
			     struct lws *wsi,
			     enum lws_token_indexes token,
			     const unsigned char *value,
			     int length,
			     unsigned char **p,
			     unsigned char *end);
LWS_VISIBLE LWS_EXTERN int
lws_add_http_header_content_length(struct lws_context *context,
				   struct lws *wsi,
				   unsigned long content_length,
				   unsigned char **p,
				   unsigned char *end);
LWS_VISIBLE LWS_EXTERN int
lws_add_http_header_status(struct lws_context *context, struct lws *wsi,
			   unsigned int code, unsigned char **p,
			   unsigned char *end);

LWS_VISIBLE LWS_EXTERN int
lws_serve_http_file(struct lws_context *context, struct lws *wsi,
		    const char *file, const char *content_type,
		    const char *other_headers, int other_headers_len);
LWS_VISIBLE LWS_EXTERN int
lws_serve_http_file_fragment(struct lws_context *context, struct lws *wsi);

LWS_VISIBLE LWS_EXTERN int
lws_return_http_status(struct lws_context *context, struct lws *wsi,
		       unsigned int code, const char *html_body);

LWS_VISIBLE LWS_EXTERN int
lws_callback_on_writable(const struct lws_context *context, struct lws 
*wsi);

LWS_VISIBLE LWS_EXTERN void
lws_get_peer_addresses(struct lws_context *context, struct lws *wsi,
		       lws_sockfd_type fd, char *name, int name_len,
		       char *rip, int rip_len);

LWS_VISIBLE LWS_EXTERN int
lws_read(struct lws_context *context, struct lws *wsi,
	 unsigned char *buf, size_t len);


Since this is fairly major, I'm checking for any outpouring of rage and 
grief first... but if we're going to do it now is the time I think...

-Andy



More information about the Libwebsockets mailing list