summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Levy <alevy@redhat.com>2012-10-19 11:21:56 +0200
committerAndy Green <andy.green@linaro.org>2012-10-19 18:27:19 +0800
commit0291eb3b958aa21cb9b75b74139ded93bd764e84 (patch)
tree482704388a7c829e399e20f0656cd6a050b6aba1
parente1be13d8b50a6e91c87eef9fea3023b2a1d4ef94 (diff)
libwebsocket_context: add userspace pointer for use before wsi creation
Signed-off-by: Alon Levy <alevy@redhat.com>
-rw-r--r--lib/libwebsockets.c10
-rw-r--r--lib/libwebsockets.h5
-rw-r--r--lib/private-libwebsockets.h2
-rw-r--r--libwebsockets-api-doc.html3
-rw-r--r--test-server/test-client.c2
-rw-r--r--test-server/test-fraggle.c2
-rw-r--r--test-server/test-ping.c2
-rw-r--r--test-server/test-server-extpoll.c2
-rw-r--r--test-server/test-server.c2
9 files changed, 22 insertions, 8 deletions
diff --git a/lib/libwebsockets.c b/lib/libwebsockets.c
index c64f245..9b22842 100644
--- a/lib/libwebsockets.c
+++ b/lib/libwebsockets.c
@@ -2118,6 +2118,12 @@ libwebsocket_context_destroy(struct libwebsocket_context *context)
#endif
}
+LWS_EXTERN void *
+libwebsocket_context_user(struct libwebsocket_context *context)
+{
+ return context->user_space;
+}
+
/**
* libwebsocket_service() - Service any pending websocket activity
* @context: Websocket context
@@ -2504,7 +2510,8 @@ libwebsocket_create_context(int port, const char *interf,
struct libwebsocket_extension *extensions,
const char *ssl_cert_filepath,
const char *ssl_private_key_filepath,
- int gid, int uid, unsigned int options)
+ int gid, int uid, unsigned int options,
+ void *user)
{
int n;
int m;
@@ -2568,6 +2575,7 @@ libwebsocket_create_context(int port, const char *interf,
context->fds_count = 0;
context->extensions = extensions;
context->last_timeout_check_s = 0;
+ context->user_space = user;
#ifdef WIN32
context->fd_random = 0;
diff --git a/lib/libwebsockets.h b/lib/libwebsockets.h
index 60e7468..719b3cb 100644
--- a/lib/libwebsockets.h
+++ b/lib/libwebsockets.h
@@ -579,7 +579,7 @@ libwebsocket_create_context(int port, const char * interf,
struct libwebsocket_extension *extensions,
const char *ssl_cert_filepath,
const char *ssl_private_key_filepath, int gid, int uid,
- unsigned int options);
+ unsigned int options, void *user);
LWS_EXTERN void
libwebsocket_context_destroy(struct libwebsocket_context *context);
@@ -594,6 +594,9 @@ LWS_EXTERN int
libwebsocket_service_fd(struct libwebsocket_context *context,
struct pollfd *pollfd);
+LWS_EXTERN void *
+libwebsocket_context_user(struct libwebsocket_context *context);
+
/*
* IMPORTANT NOTICE!
*
diff --git a/lib/private-libwebsockets.h b/lib/private-libwebsockets.h
index 3c9776f..b51a852 100644
--- a/lib/private-libwebsockets.h
+++ b/lib/private-libwebsockets.h
@@ -258,6 +258,8 @@ struct libwebsocket_context {
struct libwebsocket_protocols *protocols;
int count_protocols;
struct libwebsocket_extension *extensions;
+
+ void *user_space;
};
diff --git a/libwebsockets-api-doc.html b/libwebsockets-api-doc.html
index 18b1620..789871b 100644
--- a/libwebsockets-api-doc.html
+++ b/libwebsockets-api-doc.html
@@ -226,7 +226,8 @@ has been created.
<i>const char *</i> <b>ssl_private_key_filepath</b>,
<i>int</i> <b>gid</b>,
<i>int</i> <b>uid</b>,
-<i>unsigned int</i> <b>options</b>)
+<i>unsigned int</i> <b>options</b>,
+<i>void *</i> <b>user</b>)
<h3>Arguments</h3>
<dl>
<dt><b>port</b>
diff --git a/test-server/test-client.c b/test-server/test-client.c
index ffd6365..6db609c 100644
--- a/test-server/test-client.c
+++ b/test-server/test-client.c
@@ -258,7 +258,7 @@ int main(int argc, char **argv)
context = libwebsocket_create_context(CONTEXT_PORT_NO_LISTEN, NULL,
protocols, libwebsocket_internal_extensions,
- NULL, NULL, -1, -1, 0);
+ NULL, NULL, -1, -1, 0, NULL);
if (context == NULL) {
fprintf(stderr, "Creating libwebsocket context failed\n");
return 1;
diff --git a/test-server/test-fraggle.c b/test-server/test-fraggle.c
index 1c77d59..de544fe 100644
--- a/test-server/test-fraggle.c
+++ b/test-server/test-fraggle.c
@@ -301,7 +301,7 @@ int main(int argc, char **argv)
context = libwebsocket_create_context(server_port, interface, protocols,
libwebsocket_internal_extensions,
- cert_path, key_path, -1, -1, opts);
+ cert_path, key_path, -1, -1, opts, NULL);
if (context == NULL) {
fprintf(stderr, "libwebsocket init failed\n");
return -1;
diff --git a/test-server/test-ping.c b/test-server/test-ping.c
index 672f62c..476ef0b 100644
--- a/test-server/test-ping.c
+++ b/test-server/test-ping.c
@@ -403,7 +403,7 @@ int main(int argc, char **argv)
context = libwebsocket_create_context(CONTEXT_PORT_NO_LISTEN, NULL,
protocols,
libwebsocket_internal_extensions,
- NULL, NULL, -1, -1, 0);
+ NULL, NULL, -1, -1, 0, NULL);
if (context == NULL) {
fprintf(stderr, "Creating libwebsocket context failed\n");
return 1;
diff --git a/test-server/test-server-extpoll.c b/test-server/test-server-extpoll.c
index 8131412..f2f68b4 100644
--- a/test-server/test-server-extpoll.c
+++ b/test-server/test-server-extpoll.c
@@ -484,7 +484,7 @@ int main(int argc, char **argv)
context = libwebsocket_create_context(port, interface_ptr, protocols,
libwebsocket_internal_extensions,
- cert_path, key_path, -1, -1, opts);
+ cert_path, key_path, -1, -1, opts, NULL);
if (context == NULL) {
fprintf(stderr, "libwebsocket init failed\n");
return -1;
diff --git a/test-server/test-server.c b/test-server/test-server.c
index 516deff..9617194 100644
--- a/test-server/test-server.c
+++ b/test-server/test-server.c
@@ -447,7 +447,7 @@ int main(int argc, char **argv)
context = libwebsocket_create_context(port, interface, protocols,
libwebsocket_internal_extensions,
- cert_path, key_path, -1, -1, opts);
+ cert_path, key_path, -1, -1, opts, NULL);
if (context == NULL) {
fprintf(stderr, "libwebsocket init failed\n");
return -1;