From 3f62870e67212cd217a58488ed0419138f2bc7f2 Mon Sep 17 00:00:00 2001 From: Andy Green Date: Mon, 14 Dec 2015 07:16:32 +0800 Subject: [PATCH] introduce lws_wsi_user Signed-off-by: Andy Green --- changelog | 5 ++++- lib/libwebsockets.c | 6 ++++++ lib/libwebsockets.h | 3 +++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/changelog b/changelog index 7b54d18..22622bb 100644 --- a/changelog +++ b/changelog @@ -4,7 +4,7 @@ Changelog User api additions ------------------ -lws now exposes his internal platform file abstraction in a way that can be +1) lws now exposes his internal platform file abstraction in a way that can be both used by user code to make it platform-agnostic, and be overridden or subclassed by user code. This allows things like handling the URI "directory space" as a virtual filesystem that may or may not be backed by a regular @@ -45,6 +45,9 @@ lws_plat_file_write(struct lws_plat_file_ops *fops, lws_filefd_type fd, The user code can also override or subclass the file operations, to either wrap or replace them. An example is shown in test server. +2) A new API void * lws_wsi_user(struct lws *wsi) lets you get the pointer to +the user data associated with the wsi, just from the wsi. + User api changes ---------------- diff --git a/lib/libwebsockets.c b/lib/libwebsockets.c index 9e5b9cb..123cb61 100644 --- a/lib/libwebsockets.c +++ b/lib/libwebsockets.c @@ -941,6 +941,12 @@ lws_get_ctx(const struct lws *wsi) return wsi->context; } +LWS_VISIBLE LWS_EXTERN void * +lws_wsi_user(struct lws *wsi) +{ + return wsi->user_space; +} + #ifdef LWS_WITH_OLD_API_WRAPPERS /* diff --git a/lib/libwebsockets.h b/lib/libwebsockets.h index b94bea6..ea688bc 100644 --- a/lib/libwebsockets.h +++ b/lib/libwebsockets.h @@ -1414,6 +1414,9 @@ lws_service_fd(struct lws_context *context, LWS_VISIBLE LWS_EXTERN void * lws_context_user(struct lws_context *context); +LWS_VISIBLE LWS_EXTERN void * +lws_wsi_user(struct lws *wsi); + /* * NOTE: These public enums are part of the abi. If you want to add one, * add it at where specified so existing users are unaffected. -- 2.7.4