1
0
Fork 0
mirror of https://github.com/warmcat/libwebsockets.git synced 2025-03-09 00:00:04 +01:00

api rationalization: eliminate all libwebsocket[s]_ prefixes

This nukes all the oldstyle prefixes except in the compatibility code.

struct libwebsockets becomes struct lws too.

The api docs are updated accordingly as are the READMEs that mention
those apis.

Signed-off-by: Andy Green <andy.green@linaro.org>
This commit is contained in:
Andy Green 2015-12-04 11:08:32 +08:00
parent 6d41720233
commit 4b85c1d4ac
41 changed files with 1471 additions and 1164 deletions

View file

@ -61,8 +61,8 @@ clients).
If you want to send something, do not just send it but request a callback
when the socket is writeable using
- `libwebsocket_callback_on_writable(context, wsi)`` for a specific `wsi`, or
- `libwebsocket_callback_on_writable_all_protocol(protocol)` for all connections
- `lws_callback_on_writable(context, wsi)`` for a specific `wsi`, or
- `lws_callback_on_writable_all_protocol(protocol)` for all connections
using that protocol to get a callback when next writeable.
Usually you will get called back immediately next time around the service
@ -93,7 +93,7 @@ Closing connections from the user side
When you want to close a connection, you do it by returning `-1` from a
callback for that connection.
You can provoke a callback by calling `libwebsocket_callback_on_writable` on
You can provoke a callback by calling `lws_callback_on_writable` on
the wsi, then notice in the callback you want to close it and just return -1.
But usually, the decision to close is made in a callback already and returning
-1 is simple.
@ -112,7 +112,7 @@ Fragmented messages
-------------------
To support fragmented messages you need to check for the final
frame of a message with `libwebsocket_is_final_fragment`. This
frame of a message with `lws_is_final_fragment`. This
check can be combined with `libwebsockets_remaining_packet_payload`
to gather the whole contents of a message, eg:
@ -120,9 +120,9 @@ to gather the whole contents of a message, eg:
case LWS_CALLBACK_RECEIVE:
{
Client * const client = (Client *)user;
const size_t remaining = libwebsockets_remaining_packet_payload(wsi);
const size_t remaining = lws_remaining_packet_payload(wsi);
if (!remaining && libwebsocket_is_final_fragment(wsi)) {
if (!remaining && lws_is_final_fragment(wsi)) {
if (client->HasFragments()) {
client->AppendMessageFragment(in, len, 0);
in = (void *)client->GetMessage();
@ -178,7 +178,7 @@ Four callbacks `LWS_CALLBACK_ADD_POLL_FD`, `LWS_CALLBACK_DEL_POLL_FD`,
appear in the callback for protocol 0 and allow interface code to
manage socket descriptors in other poll loops.
You can pass all pollfds that need service to `libwebsocket_service_fd()`, even
You can pass all pollfds that need service to `lws_service_fd()`, even
if the socket or file does not belong to **libwebsockets** it is safe.
If **libwebsocket** handled it, it zeros the pollfd `revents` field before returning.
@ -261,7 +261,7 @@ if left `NULL`, then the "DEFAULT" set of ciphers are all possible to select.
Async nature of client connections
----------------------------------
When you call `libwebsocket_client_connect(..)` and get a `wsi` back, it does not
When you call `lws_client_connect(..)` and get a `wsi` back, it does not
mean your connection is active. It just mean it started trying to connect.
Your client connection is actually active only when you receive
@ -273,6 +273,6 @@ other reasons, if any of that happens you'll get a
`wsi`.
After attempting the connection and getting back a non-`NULL` `wsi` you should
loop calling `libwebsocket_service()` until one of the above callbacks occurs.
loop calling `lws_service()` until one of the above callbacks occurs.
As usual, see [test-client.c](test-server/test-client.c) for example code.

View file

@ -1,10 +1,10 @@
#include "private-libwebsockets.h"
struct libwebsocket *lws_client_connect_2(
struct libwebsocket_context *context,
struct libwebsocket *wsi
struct lws *lws_client_connect_2(
struct lws_context *context,
struct lws *wsi
) {
struct libwebsocket_pollfd pfd;
struct lws_pollfd pfd;
#ifdef LWS_USE_IPV6
struct sockaddr_in6 server_addr6;
struct sockaddr_in6 client_addr6;
@ -333,8 +333,8 @@ failed:
* This function creates a connection to a remote server
*/
LWS_VISIBLE struct libwebsocket *
lws_client_connect(struct libwebsocket_context *context,
LWS_VISIBLE struct lws *
lws_client_connect(struct lws_context *context,
const char *address,
int port,
int ssl_connection,
@ -344,9 +344,9 @@ lws_client_connect(struct libwebsocket_context *context,
const char *protocol,
int ietf_version_or_minus_one)
{
struct libwebsocket *wsi;
struct lws *wsi;
wsi = lws_zalloc(sizeof(struct libwebsocket));
wsi = lws_zalloc(sizeof(struct lws));
if (wsi == NULL)
goto bail;
@ -458,8 +458,8 @@ bail:
* This function creates a connection to a remote server
*/
LWS_VISIBLE struct libwebsocket *
lws_client_connect_extended(struct libwebsocket_context *context,
LWS_VISIBLE struct lws *
lws_client_connect_extended(struct lws_context *context,
const char *address,
int port,
int ssl_connection,
@ -470,7 +470,7 @@ lws_client_connect_extended(struct libwebsocket_context *context,
int ietf_version_or_minus_one,
void *userdata)
{
struct libwebsocket *ws =
struct lws *ws =
lws_client_connect(context, address, port,
ssl_connection, path, host, origin, protocol,
ietf_version_or_minus_one);

View file

@ -21,7 +21,7 @@
#include "private-libwebsockets.h"
int lws_client_rx_sm(struct libwebsocket *wsi, unsigned char c)
int lws_client_rx_sm(struct lws *wsi, unsigned char c)
{
int callback_action = LWS_CALLBACK_CLIENT_RECEIVE;
int handled;
@ -407,7 +407,7 @@ ping_drop:
m = wsi->protocol->callback(
wsi->protocol->owning_server,
wsi,
(enum libwebsocket_callback_reasons)callback_action,
(enum lws_callback_reasons)callback_action,
wsi->user_space,
eff_buf.token,
eff_buf.token_len);

View file

@ -21,7 +21,7 @@
#include "private-libwebsockets.h"
int lws_handshake_client(struct libwebsocket *wsi, unsigned char **buf, size_t len)
int lws_handshake_client(struct lws *wsi, unsigned char **buf, size_t len)
{
int n;
@ -43,8 +43,8 @@ int lws_handshake_client(struct libwebsocket *wsi, unsigned char **buf, size_t l
return 0;
}
int lws_client_socket_service(struct libwebsocket_context *context,
struct libwebsocket *wsi, struct libwebsocket_pollfd *pollfd)
int lws_client_socket_service(struct lws_context *context,
struct lws *wsi, struct lws_pollfd *pollfd)
{
int n;
char *p = (char *)&context->service_buffer[0];
@ -492,8 +492,8 @@ strtolower(char *s)
}
int
lws_client_interpret_server_handshake(struct libwebsocket_context *context,
struct libwebsocket *wsi)
lws_client_interpret_server_handshake(struct lws_context *context,
struct lws *wsi)
{
const char *pc;
int okay = 0;
@ -502,7 +502,7 @@ lws_client_interpret_server_handshake(struct libwebsocket_context *context,
int isErrorCodeReceived = 0;
#ifndef LWS_NO_EXTENSIONS
char ext_name[128];
struct libwebsocket_extension *ext;
struct lws_extension *ext;
void *v;
int more = 1;
const char *c;
@ -832,8 +832,8 @@ bail2:
char *
lws_generate_client_handshake(struct libwebsocket_context *context,
struct libwebsocket *wsi, char *pkt)
lws_generate_client_handshake(struct lws_context *context,
struct lws *wsi, char *pkt)
{
char buf[128];
char hash[20];
@ -841,7 +841,7 @@ lws_generate_client_handshake(struct libwebsocket_context *context,
char *p = pkt;
int n;
#ifndef LWS_NO_EXTENSIONS
struct libwebsocket_extension *ext;
struct lws_extension *ext;
int ext_count = 0;
#endif

View file

@ -48,7 +48,7 @@ lws_get_library_version(void)
* This function creates the listening socket (if serving) and takes care
* of all initialization in one step.
*
* After initialization, it returns a struct libwebsocket_context * that
* After initialization, it returns a struct lws_context * that
* represents this server. After calling, user code needs to take care
* of calling lws_service() with the context pointer to get the
* server's sockets serviced. This must be done in the same process
@ -71,10 +71,10 @@ lws_get_library_version(void)
* one place; they're all handled in the user callback.
*/
LWS_VISIBLE struct libwebsocket_context *
LWS_VISIBLE struct lws_context *
lws_create_context(struct lws_context_creation_info *info)
{
struct libwebsocket_context *context = NULL;
struct lws_context *context = NULL;
char *p;
#if LWS_POSIX
int pid_daemon = get_daemonize_pid();
@ -106,7 +106,7 @@ lws_create_context(struct lws_context_creation_info *info)
if (lws_plat_context_early_init())
return NULL;
context = lws_zalloc(sizeof(struct libwebsocket_context));
context = lws_zalloc(sizeof(struct lws_context));
if (!context) {
lwsl_err("No memory for websocket context\n");
return NULL;
@ -149,16 +149,16 @@ lws_create_context(struct lws_context_creation_info *info)
/* to reduce this allocation, */
context->max_fds = getdtablesize();
lwsl_notice(" static allocation: %u + (%u x %u fds) = %u bytes\n",
sizeof(struct libwebsocket_context),
sizeof(struct libwebsocket_pollfd) +
sizeof(struct libwebsocket *),
sizeof(struct lws_context),
sizeof(struct lws_pollfd) +
sizeof(struct lws *),
context->max_fds,
sizeof(struct libwebsocket_context) +
((sizeof(struct libwebsocket_pollfd) +
sizeof(struct libwebsocket *)) *
sizeof(struct lws_context) +
((sizeof(struct lws_pollfd) +
sizeof(struct lws *)) *
context->max_fds));
context->fds = lws_zalloc(sizeof(struct libwebsocket_pollfd) *
context->fds = lws_zalloc(sizeof(struct lws_pollfd) *
context->max_fds);
if (context->fds == NULL) {
lwsl_err("Unable to allocate fds array for %d connections\n",
@ -197,7 +197,7 @@ lws_create_context(struct lws_context_creation_info *info)
lwsl_notice(
" per-conn mem: %u + %u headers + protocol rx buf\n",
sizeof(struct libwebsocket),
sizeof(struct lws),
sizeof(struct allocated_headers));
if (lws_context_init_server_ssl(info, context))
@ -270,12 +270,12 @@ bail:
* undefined.
*/
LWS_VISIBLE void
lws_context_destroy(struct libwebsocket_context *context)
lws_context_destroy(struct lws_context *context)
{
/* Note that this is used for freeing partially allocated structs as well
* so make sure you don't try to free something uninitialized */
int n;
struct libwebsocket_protocols *protocol = NULL;
struct lws_protocols *protocol = NULL;
lwsl_notice("%s\n", __func__);
@ -288,7 +288,7 @@ lws_context_destroy(struct libwebsocket_context *context)
#endif
for (n = 0; n < context->fds_count; n++) {
struct libwebsocket *wsi =
struct lws *wsi =
wsi_from_fd(context, context->fds[n].fd);
if (!wsi)
continue;

View file

@ -8,10 +8,10 @@
#define LWS_ZLIB_MEMLEVEL 8
int lws_extension_callback_deflate_frame(
struct libwebsocket_context *context,
struct libwebsocket_extension *ext,
struct libwebsocket *wsi,
enum libwebsocket_extension_callback_reasons reason,
struct lws_context *context,
struct lws_extension *ext,
struct lws *wsi,
enum lws_extension_callback_reasons reason,
void *user, void *in, size_t len)
{
struct lws_ext_deflate_frame_conn *conn =

View file

@ -18,8 +18,8 @@ struct lws_ext_deflate_frame_conn {
};
extern int lws_extension_callback_deflate_frame(
struct libwebsocket_context *context,
struct libwebsocket_extension *ext,
struct libwebsocket *wsi,
enum libwebsocket_extension_callback_reasons reason,
struct lws_context *context,
struct lws_extension *ext,
struct lws *wsi,
enum lws_extension_callback_reasons reason,
void *user, void *in, size_t len);

View file

@ -8,10 +8,10 @@
#define LWS_ZLIB_MEMLEVEL 8
int lws_extension_callback_deflate_stream(
struct libwebsocket_context *context,
struct libwebsocket_extension *ext,
struct libwebsocket *wsi,
enum libwebsocket_extension_callback_reasons reason,
struct lws_context *context,
struct lws_extension *ext,
struct lws *wsi,
enum lws_extension_callback_reasons reason,
void *user, void *in, size_t len)
{
struct lws_ext_deflate_stream_conn *conn =

View file

@ -13,8 +13,8 @@ struct lws_ext_deflate_stream_conn {
};
extern int lws_extension_callback_deflate_stream(
struct libwebsocket_context *context,
struct libwebsocket_extension *ext,
struct libwebsocket *wsi,
enum libwebsocket_extension_callback_reasons reason,
struct lws_context *context,
struct lws_extension *ext,
struct lws *wsi,
enum lws_extension_callback_reasons reason,
void *user, void *in, size_t len);

View file

@ -3,7 +3,7 @@
#include "extension-deflate-frame.h"
#include "extension-deflate-stream.h"
struct libwebsocket_extension libwebsocket_internal_extensions[] = {
struct lws_extension lws_internal_extensions[] = {
#ifdef LWS_EXT_DEFLATE_STREAM
{
"deflate-stream",
@ -29,21 +29,21 @@ struct libwebsocket_extension libwebsocket_internal_extensions[] = {
LWS_VISIBLE void
lws_context_init_extensions(struct lws_context_creation_info *info,
struct libwebsocket_context *context)
struct lws_context *context)
{
context->extensions = info->extensions;
lwsl_info(" LWS_MAX_EXTENSIONS_ACTIVE: %u\n", LWS_MAX_EXTENSIONS_ACTIVE);
}
LWS_VISIBLE struct libwebsocket_extension *lws_get_internal_extensions()
LWS_VISIBLE struct lws_extension *lws_get_internal_extensions()
{
return libwebsocket_internal_extensions;
return lws_internal_extensions;
}
/* 0 = nobody had nonzero return, 1 = somebody had positive return, -1 = fail */
int lws_ext_callback_for_each_active(struct libwebsocket *wsi, int reason,
int lws_ext_callback_for_each_active(struct lws *wsi, int reason,
void *arg, int len)
{
int n, m, handled = 0;
@ -69,11 +69,11 @@ int lws_ext_callback_for_each_active(struct libwebsocket *wsi, int reason,
}
int lws_ext_callback_for_each_extension_type(
struct libwebsocket_context *context, struct libwebsocket *wsi,
struct lws_context *context, struct lws *wsi,
int reason, void *arg, int len)
{
int n = 0, m, handled = 0;
struct libwebsocket_extension *ext = context->extensions;
struct lws_extension *ext = context->extensions;
while (ext && ext->callback && !handled) {
m = ext->callback(context, ext, wsi, reason,
@ -95,7 +95,7 @@ int lws_ext_callback_for_each_extension_type(
}
int
lws_issue_raw_ext_access(struct libwebsocket *wsi,
lws_issue_raw_ext_access(struct lws *wsi,
unsigned char *buf, size_t len)
{
int ret;
@ -185,9 +185,9 @@ lws_issue_raw_ext_access(struct libwebsocket *wsi,
}
int
lws_any_extension_handled(struct libwebsocket_context *context,
struct libwebsocket *wsi,
enum libwebsocket_extension_callback_reasons r,
lws_any_extension_handled(struct lws_context *context,
struct lws *wsi,
enum lws_extension_callback_reasons r,
void *v, size_t len)
{
int n;

View file

@ -57,8 +57,8 @@
*/
LWS_VISIBLE int
lws_read(struct libwebsocket_context *context,
struct libwebsocket *wsi, unsigned char *buf, size_t len)
lws_read(struct lws_context *context,
struct lws *wsi, unsigned char *buf, size_t len)
{
size_t n;
int body_chunk_len;

View file

@ -29,8 +29,8 @@ const unsigned char *lws_token_to_string(enum lws_token_indexes token)
return (unsigned char *)set[token];
}
int lws_add_http_header_by_name(struct libwebsocket_context *context,
struct libwebsocket *wsi,
int lws_add_http_header_by_name(struct lws_context *context,
struct lws *wsi,
const unsigned char *name,
const unsigned char *value,
int length,
@ -61,8 +61,8 @@ int lws_add_http_header_by_name(struct libwebsocket_context *context,
return 0;
}
int lws_finalize_http_header(struct libwebsocket_context *context,
struct libwebsocket *wsi,
int lws_finalize_http_header(struct lws_context *context,
struct lws *wsi,
unsigned char **p,
unsigned char *end)
{
@ -80,8 +80,8 @@ int lws_finalize_http_header(struct libwebsocket_context *context,
return 0;
}
int lws_add_http_header_by_token(struct libwebsocket_context *context,
struct libwebsocket *wsi,
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,
@ -99,8 +99,8 @@ int lws_add_http_header_by_token(struct libwebsocket_context *context,
return lws_add_http_header_by_name(context, wsi, name, value, length, p, end);
}
int lws_add_http_header_content_length(struct libwebsocket_context *context,
struct libwebsocket *wsi,
int lws_add_http_header_content_length(struct lws_context *context,
struct lws *wsi,
unsigned long content_length,
unsigned char **p,
unsigned char *end)
@ -147,8 +147,8 @@ static const char *err500[] = {
"HTTP Version Not Supported"
};
int lws_add_http_header_status(struct libwebsocket_context *context,
struct libwebsocket *wsi,
int lws_add_http_header_status(struct lws_context *context,
struct lws *wsi,
unsigned int code,
unsigned char **p,
unsigned char *end)
@ -182,7 +182,7 @@ int lws_add_http_header_status(struct libwebsocket_context *context,
* consistently
*/
LWS_VISIBLE int lws_return_http_status(
struct libwebsocket_context *context, struct libwebsocket *wsi,
struct lws_context *context, struct lws *wsi,
unsigned int code, const char *html_body)
{
int n, m;

View file

@ -189,13 +189,13 @@ static int huftable_decode(int pos, char c)
return pos + (lextable[q] << 1);
}
static int lws_hpack_update_table_size(struct libwebsocket *wsi, int idx)
static int lws_hpack_update_table_size(struct lws *wsi, int idx)
{
lwsl_info("hpack set table size %d\n", idx);
return 0;
}
static int lws_frag_start(struct libwebsocket *wsi, int hdr_token_idx)
static int lws_frag_start(struct lws *wsi, int hdr_token_idx)
{
struct allocated_headers * ah = wsi->u.http2.http.ah;
@ -214,7 +214,7 @@ static int lws_frag_start(struct libwebsocket *wsi, int hdr_token_idx)
return 0;
}
static int lws_frag_append(struct libwebsocket *wsi, unsigned char c)
static int lws_frag_append(struct lws *wsi, unsigned char c)
{
struct allocated_headers * ah = wsi->u.http2.http.ah;
@ -224,7 +224,7 @@ static int lws_frag_append(struct libwebsocket *wsi, unsigned char c)
return ah->pos >= sizeof(ah->data);
}
static int lws_frag_end(struct libwebsocket *wsi)
static int lws_frag_end(struct lws *wsi)
{
if (lws_frag_append(wsi, 0))
return 1;
@ -233,7 +233,7 @@ static int lws_frag_end(struct libwebsocket *wsi)
return 0;
}
static void lws_dump_header(struct libwebsocket *wsi, int hdr)
static void lws_dump_header(struct lws *wsi, int hdr)
{
char s[200];
int len = lws_hdr_copy(wsi, s, sizeof(s) - 1, hdr);
@ -241,7 +241,7 @@ static void lws_dump_header(struct libwebsocket *wsi, int hdr)
lwsl_info(" hdr tok %d (%s) = '%s'\n", hdr, lws_token_to_string(hdr), s);
}
static int lws_token_from_index(struct libwebsocket *wsi, int index, char **arg, int *len)
static int lws_token_from_index(struct lws *wsi, int index, char **arg, int *len)
{
struct hpack_dynamic_table *dyn;
@ -269,7 +269,7 @@ static int lws_token_from_index(struct libwebsocket *wsi, int index, char **arg,
return dyn->entries[index].token;
}
static int lws_hpack_add_dynamic_header(struct libwebsocket *wsi, int token, char *arg, int len)
static int lws_hpack_add_dynamic_header(struct lws *wsi, int token, char *arg, int len)
{
struct hpack_dynamic_table *dyn;
int ret = 1;
@ -321,7 +321,7 @@ bail1:
return ret;
}
static int lws_write_indexed_hdr(struct libwebsocket *wsi, int idx)
static int lws_write_indexed_hdr(struct lws *wsi, int idx)
{
const char *p;
int tok = lws_token_from_index(wsi, idx, NULL, 0);
@ -345,8 +345,8 @@ static int lws_write_indexed_hdr(struct libwebsocket *wsi, int idx)
return 0;
}
int lws_hpack_interpret(struct libwebsocket_context *context,
struct libwebsocket *wsi, unsigned char c)
int lws_hpack_interpret(struct lws_context *context,
struct lws *wsi, unsigned char c)
{
unsigned int prev;
unsigned char c1;
@ -609,8 +609,8 @@ static int lws_http2_num(int starting_bits, unsigned long num, unsigned char **p
return 0;
}
int lws_add_http2_header_by_name(struct libwebsocket_context *context,
struct libwebsocket *wsi,
int lws_add_http2_header_by_name(struct lws_context *context,
struct lws *wsi,
const unsigned char *name,
const unsigned char *value,
int length,
@ -647,8 +647,8 @@ int lws_add_http2_header_by_name(struct libwebsocket_context *context,
return 0;
}
int lws_add_http2_header_by_token(struct libwebsocket_context *context,
struct libwebsocket *wsi,
int lws_add_http2_header_by_token(struct lws_context *context,
struct lws *wsi,
enum lws_token_indexes token,
const unsigned char *value,
int length,
@ -664,8 +664,8 @@ int lws_add_http2_header_by_token(struct libwebsocket_context *context,
return lws_add_http2_header_by_name(context, wsi, name, value, length, p, end);
}
int lws_add_http2_header_status(struct libwebsocket_context *context,
struct libwebsocket *wsi,
int lws_add_http2_header_status(struct lws_context *context,
struct lws *wsi,
unsigned int code,
unsigned char **p,
unsigned char *end)

View file

@ -38,8 +38,8 @@ void lws_http2_init(struct http2_settings *settings)
memcpy(settings, lws_http2_default_settings.setting, sizeof(*settings));
}
struct libwebsocket *
lws_http2_wsi_from_id(struct libwebsocket *wsi, unsigned int sid)
struct lws *
lws_http2_wsi_from_id(struct lws *wsi, unsigned int sid)
{
do {
if (wsi->u.http2.my_stream_id == sid)
@ -51,10 +51,10 @@ lws_http2_wsi_from_id(struct libwebsocket *wsi, unsigned int sid)
return NULL;
}
struct libwebsocket *
lws_create_server_child_wsi(struct libwebsocket_context *context, struct libwebsocket *parent_wsi, unsigned int sid)
struct lws *
lws_create_server_child_wsi(struct lws_context *context, struct lws *parent_wsi, unsigned int sid)
{
struct libwebsocket *wsi = lws_create_new_server_wsi(context);
struct lws *wsi = lws_create_new_server_wsi(context);
if (!wsi)
return NULL;
@ -87,9 +87,9 @@ lws_create_server_child_wsi(struct libwebsocket_context *context, struct libwebs
return wsi;
}
int lws_remove_server_child_wsi(struct libwebsocket_context *context, struct libwebsocket *wsi)
int lws_remove_server_child_wsi(struct lws_context *context, struct lws *wsi)
{
struct libwebsocket **w = &wsi->u.http2.parent_wsi;
struct lws **w = &wsi->u.http2.parent_wsi;
do {
if (*w == wsi) {
*w = wsi->u.http2.next_child_wsi;
@ -132,7 +132,7 @@ lws_http2_interpret_settings_payload(struct http2_settings *settings, unsigned c
return 0;
}
struct libwebsocket *lws_http2_get_network_wsi(struct libwebsocket *wsi)
struct lws *lws_http2_get_network_wsi(struct lws *wsi)
{
while (wsi->u.http2.parent_wsi)
wsi = wsi->u.http2.parent_wsi;
@ -140,9 +140,9 @@ struct libwebsocket *lws_http2_get_network_wsi(struct libwebsocket *wsi)
return wsi;
}
int lws_http2_frame_write(struct libwebsocket *wsi, int type, int flags, unsigned int sid, unsigned int len, unsigned char *buf)
int lws_http2_frame_write(struct lws *wsi, int type, int flags, unsigned int sid, unsigned int len, unsigned char *buf)
{
struct libwebsocket *wsi_eff = lws_http2_get_network_wsi(wsi);
struct lws *wsi_eff = lws_http2_get_network_wsi(wsi);
unsigned char *p = &buf[-LWS_HTTP2_FRAME_HEADER_LENGTH];
int n;
@ -172,7 +172,7 @@ int lws_http2_frame_write(struct libwebsocket *wsi, int type, int flags, unsigne
return n;
}
static void lws_http2_settings_write(struct libwebsocket *wsi, int n, unsigned char *buf)
static void lws_http2_settings_write(struct lws *wsi, int n, unsigned char *buf)
{
*buf++ = n >> 8;
*buf++ = n;
@ -186,12 +186,12 @@ static const char * https_client_preface =
"PRI * HTTP/2.0\x0d\x0a\x0d\x0aSM\x0d\x0a\x0d\x0a";
int
lws_http2_parser(struct libwebsocket_context *context,
struct libwebsocket *wsi, unsigned char c)
lws_http2_parser(struct lws_context *context,
struct lws *wsi, unsigned char c)
{
struct libwebsocket *swsi;
struct lws *swsi;
int n;
//dstruct libwebsocket *wsi_new;
//dstruct lws *wsi_new;
switch (wsi->state) {
case WSI_STATE_HTTP2_AWAIT_CLIENT_PREFACE:
@ -413,10 +413,10 @@ update_end_headers:
return 0;
}
int lws_http2_do_pps_send(struct libwebsocket_context *context, struct libwebsocket *wsi)
int lws_http2_do_pps_send(struct lws_context *context, struct lws *wsi)
{
unsigned char settings[LWS_SEND_BUFFER_PRE_PADDING + 6 * LWS_HTTP2_SETTINGS__COUNT];
struct libwebsocket *swsi;
struct lws *swsi;
int n, m = 0;
lwsl_debug("%s: %p: %d\n", __func__, wsi, wsi->pps);
@ -497,7 +497,7 @@ int lws_http2_do_pps_send(struct libwebsocket_context *context, struct libwebsoc
return 0;
}
struct libwebsocket * lws_http2_get_nth_child(struct libwebsocket *wsi, int n)
struct lws * lws_http2_get_nth_child(struct lws *wsi, int n)
{
do {
wsi = wsi->u.http2.next_child_wsi;

View file

@ -32,9 +32,9 @@ void lws_feature_status_libev(struct lws_context_creation_info *info)
static void
lws_accept_cb(struct ev_loop *loop, struct ev_io *watcher, int revents)
{
struct libwebsocket_pollfd eventfd;
struct lws_pollfd eventfd;
struct lws_io_watcher *lws_io = container_of(watcher, struct lws_io_watcher, watcher);
struct libwebsocket_context *context = lws_io->context;
struct lws_context *context = lws_io->context;
if (revents & EV_ERROR)
return;
@ -58,7 +58,7 @@ lws_sigint_cb(struct ev_loop *loop,
}
LWS_VISIBLE int lws_sigint_cfg(
struct libwebsocket_context *context,
struct lws_context *context,
int use_ev_sigint,
lws_ev_signal_cb* cb)
{
@ -74,7 +74,7 @@ LWS_VISIBLE int lws_sigint_cfg(
LWS_VISIBLE int
lws_initloop(
struct libwebsocket_context *context,
struct lws_context *context,
struct ev_loop *loop)
{
int status = 0;
@ -133,8 +133,8 @@ lws_initloop(
}
LWS_VISIBLE void
lws_libev_accept(struct libwebsocket_context *context,
struct libwebsocket *new_wsi, int accept_fd)
lws_libev_accept(struct lws_context *context,
struct lws *new_wsi, int accept_fd)
{
struct ev_io *r = &new_wsi->w_read.watcher;
struct ev_io *w = &new_wsi->w_write.watcher;
@ -149,8 +149,8 @@ lws_libev_accept(struct libwebsocket_context *context,
}
LWS_VISIBLE void
lws_libev_io(struct libwebsocket_context *context,
struct libwebsocket *wsi, int flags)
lws_libev_io(struct lws_context *context,
struct lws *wsi, int flags)
{
if (!LWS_LIBEV_ENABLED(context))
return;
@ -175,7 +175,7 @@ lws_libev_io(struct libwebsocket_context *context,
}
LWS_VISIBLE int
lws_libev_init_fd_table(struct libwebsocket_context *context)
lws_libev_init_fd_table(struct lws_context *context)
{
if (!LWS_LIBEV_ENABLED(context))
return 0;
@ -187,7 +187,7 @@ lws_libev_init_fd_table(struct libwebsocket_context *context)
}
LWS_VISIBLE void
lws_libev_run(struct libwebsocket_context *context)
lws_libev_run(struct lws_context *context)
{
if (context->io_loop && LWS_LIBEV_ENABLED(context))
ev_run(context->io_loop, 0);

View file

@ -38,7 +38,7 @@ static const char * const log_level_names[] = {
};
void
lws_free_wsi(struct libwebsocket *wsi)
lws_free_wsi(struct lws *wsi)
{
if (!wsi)
return;
@ -61,8 +61,8 @@ lws_free_wsi(struct libwebsocket *wsi)
}
void
lws_close_and_free_session(struct libwebsocket_context *context,
struct libwebsocket *wsi, enum lws_close_status reason)
lws_close_and_free_session(struct lws_context *context,
struct lws *wsi, enum lws_close_status reason)
{
int n, m, ret;
int old_state;
@ -324,7 +324,7 @@ just_kill_connection:
}
LWS_VISIBLE int
lws_get_addresses(struct libwebsocket_context *context,
lws_get_addresses(struct lws_context *context,
void *ads, char *name, int name_len,
char *rip, int rip_len)
{
@ -408,7 +408,7 @@ lws_get_addresses(struct libwebsocket_context *context,
/**
* lws_get_peer_addresses() - Get client address information
* @context: Libwebsockets context
* @wsi: Local struct libwebsocket associated with
* @wsi: Local struct lws associated with
* @fd: Connection socket descriptor
* @name: Buffer to take client address name
* @name_len: Length of client address name buffer
@ -422,8 +422,8 @@ lws_get_addresses(struct libwebsocket_context *context,
*/
LWS_VISIBLE void
lws_get_peer_addresses(struct libwebsocket_context *context,
struct libwebsocket *wsi, lws_sockfd_type fd, char *name, int name_len,
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)
{
#if LWS_POSIX
@ -481,7 +481,7 @@ bail:
* using globals statics in the user code.
*/
LWS_EXTERN void *
lws_context_user(struct libwebsocket_context *context)
lws_context_user(struct lws_context *context)
{
return context->user_space;
}
@ -497,11 +497,11 @@ lws_context_user(struct libwebsocket_context *context)
LWS_VISIBLE int
lws_callback_all_protocol(
const struct libwebsocket_protocols *protocol, int reason)
const struct lws_protocols *protocol, int reason)
{
struct libwebsocket_context *context = protocol->owning_server;
struct lws_context *context = protocol->owning_server;
int n;
struct libwebsocket *wsi;
struct lws *wsi;
for (n = 0; n < context->fds_count; n++) {
wsi = wsi_from_fd(context, context->fds[n].fd);
@ -526,7 +526,7 @@ lws_callback_all_protocol(
*/
LWS_VISIBLE void
lws_set_timeout(struct libwebsocket *wsi,
lws_set_timeout(struct lws *wsi,
enum pending_timeout reason, int secs)
{
time_t now;
@ -549,7 +549,7 @@ lws_set_timeout(struct libwebsocket *wsi,
*/
LWS_VISIBLE int
lws_get_socket_fd(struct libwebsocket *wsi)
lws_get_socket_fd(struct lws *wsi)
{
return wsi->sock;
}
@ -558,7 +558,7 @@ lws_get_socket_fd(struct libwebsocket *wsi)
#ifdef LWS_LATENCY
void
lws_latency(struct libwebsocket_context *context, struct libwebsocket *wsi,
lws_latency(struct lws_context *context, struct lws *wsi,
const char *action, int ret, int completed)
{
unsigned long long u;
@ -611,7 +611,7 @@ lws_latency(struct libwebsocket_context *context, struct libwebsocket *wsi,
*/
LWS_VISIBLE int
lws_rx_flow_control(struct libwebsocket *wsi, int enable)
lws_rx_flow_control(struct lws *wsi, int enable)
{
if (enable == (wsi->rxflow_change_to & LWS_RXFLOW_ALLOW))
return 0;
@ -634,11 +634,11 @@ lws_rx_flow_control(struct libwebsocket *wsi, int enable)
LWS_VISIBLE void
lws_rx_flow_allow_all_protocol(
const struct libwebsocket_protocols *protocol)
const struct lws_protocols *protocol)
{
struct libwebsocket_context *context = protocol->owning_server;
struct lws_context *context = protocol->owning_server;
int n;
struct libwebsocket *wsi;
struct lws *wsi;
for (n = 0; n < context->fds_count; n++) {
wsi = wsi_from_fd(context, context->fds[n].fd);
@ -660,15 +660,15 @@ lws_rx_flow_allow_all_protocol(
* @context: Websocket context
*/
LWS_VISIBLE extern const char *
lws_canonical_hostname(struct libwebsocket_context *context)
lws_canonical_hostname(struct lws_context *context)
{
return (const char *)context->canonical_hostname;
}
int user_callback_handle_rxflow(callback_function callback_function,
struct libwebsocket_context *context,
struct libwebsocket *wsi,
enum libwebsocket_callback_reasons reason, void *user,
struct lws_context *context,
struct lws *wsi,
enum lws_callback_reasons reason, void *user,
void *in, size_t len)
{
int n;
@ -682,8 +682,8 @@ int user_callback_handle_rxflow(callback_function callback_function,
/**
* lws_set_proxy() - Setups proxy to libwebsocket_context.
* @context: pointer to struct libwebsocket_context you want set proxy to
* lws_set_proxy() - Setups proxy to lws_context.
* @context: pointer to struct lws_context you want set proxy to
* @proxy: pointer to c string containing proxy in format address:port
*
* Returns 0 if proxy string was parsed and proxy was setup.
@ -693,14 +693,14 @@ int user_callback_handle_rxflow(callback_function callback_function,
* environment variable (eg, OSX)
*
* IMPORTANT! You should call this function right after creation of the
* libwebsocket_context and before call to connect. If you call this
* lws_context and before call to connect. If you call this
* function after connect behavior is undefined.
* This function will override proxy settings made on libwebsocket_context
* This function will override proxy settings made on lws_context
* creation with genenv() call.
*/
LWS_VISIBLE int
lws_set_proxy(struct libwebsocket_context *context, const char *proxy)
lws_set_proxy(struct lws_context *context, const char *proxy)
{
char *p;
char authstring[96];
@ -763,26 +763,26 @@ auth_too_long:
* this is how you can get a pointer to the active protocol if needed.
*/
LWS_VISIBLE const struct libwebsocket_protocols *
lws_get_protocol(struct libwebsocket *wsi)
LWS_VISIBLE const struct lws_protocols *
lws_get_protocol(struct lws *wsi)
{
return wsi->protocol;
}
LWS_VISIBLE int
lws_is_final_fragment(struct libwebsocket *wsi)
lws_is_final_fragment(struct lws *wsi)
{
return wsi->u.ws.final;
}
LWS_VISIBLE unsigned char
lws_get_reserved_bits(struct libwebsocket *wsi)
lws_get_reserved_bits(struct lws *wsi)
{
return wsi->u.ws.rsv;
}
int
lws_ensure_user_space(struct libwebsocket *wsi)
lws_ensure_user_space(struct lws *wsi)
{
lwsl_info("%s: %p protocol %p\n", __func__, wsi, wsi->protocol);
if (!wsi->protocol)
@ -870,7 +870,7 @@ LWS_VISIBLE void lws_set_log_level(int level, void (*log_emit_function)(int leve
* checked (appears for client wsi told to skip check on connection)
*/
LWS_VISIBLE int
lws_is_ssl(struct libwebsocket *wsi)
lws_is_ssl(struct lws *wsi)
{
#ifdef LWS_OPENSSL_SUPPORT
return wsi->use_ssl;
@ -898,13 +898,13 @@ lws_is_ssl(struct libwebsocket *wsi)
*/
LWS_VISIBLE int
lws_partial_buffered(struct libwebsocket *wsi)
lws_partial_buffered(struct lws *wsi)
{
return !!wsi->truncated_send_len;
}
void lws_set_protocol_write_pending(struct libwebsocket_context *context,
struct libwebsocket *wsi,
void lws_set_protocol_write_pending(struct lws_context *context,
struct lws *wsi,
enum lws_pending_protocol_send pend)
{
lwsl_info("setting pps %d\n", pend);
@ -917,7 +917,7 @@ void lws_set_protocol_write_pending(struct libwebsocket_context *context,
}
LWS_VISIBLE size_t
lws_get_peer_write_allowance(struct libwebsocket *wsi)
lws_get_peer_write_allowance(struct lws *wsi)
{
#ifdef LWS_USE_HTTP2
/* only if we are using HTTP2 on this connection */
@ -935,7 +935,7 @@ lws_get_peer_write_allowance(struct libwebsocket *wsi)
}
LWS_VISIBLE void
lws_union_transition(struct libwebsocket *wsi, enum connection_mode mode)
lws_union_transition(struct lws *wsi, enum connection_mode mode)
{
memset(&wsi->u, 0, sizeof(wsi->u));
wsi->mode = mode;
@ -959,8 +959,10 @@ lws_union_transition(struct libwebsocket *wsi, enum connection_mode mode)
* libwebsockets.h will map them at compile time.
*/
#undef libwebsocket
#undef libwebsocket_create_context
LWS_VISIBLE LWS_EXTERN struct libwebsocket_context *
LWS_VISIBLE LWS_EXTERN struct lws_context *
libwebsocket_create_context(struct lws_context_creation_info *info)
{
return lws_create_context(info);
@ -968,28 +970,28 @@ libwebsocket_create_context(struct lws_context_creation_info *info)
#undef libwebsocket_set_proxy
LWS_VISIBLE LWS_EXTERN int
libwebsocket_set_proxy(struct libwebsocket_context *context, const char *proxy)
libwebsocket_set_proxy(struct lws_context *context, const char *proxy)
{
return lws_set_proxy(context, proxy);
}
#undef libwebsocket_context_destroy
#undef lws_context_destroy
LWS_VISIBLE LWS_EXTERN void
libwebsocket_context_destroy(struct libwebsocket_context *context)
libwebsocket_context_destroy(struct lws_context *context)
{
lws_context_destroy(context);
}
#undef libwebsocket_service
LWS_VISIBLE LWS_EXTERN int
libwebsocket_service(struct libwebsocket_context *context, int timeout_ms)
libwebsocket_service(struct lws_context *context, int timeout_ms)
{
return lws_service(context, timeout_ms);
}
#undef libwebsocket_cancel_service
LWS_VISIBLE LWS_EXTERN void
libwebsocket_cancel_service(struct libwebsocket_context *context)
libwebsocket_cancel_service(struct lws_context *context)
{
lws_cancel_service(context);
}
@ -998,7 +1000,7 @@ libwebsocket_cancel_service(struct libwebsocket_context *context)
#undef libwebsocket_sigint_cfg
LWS_VISIBLE LWS_EXTERN int
libwebsocket_sigint_cfg(
struct libwebsocket_context *context,
struct lws_context *context,
int use_ev_sigint,
lws_ev_signal_cb* cb)
{
@ -1007,7 +1009,7 @@ libwebsocket_sigint_cfg(
#undef libwebsocket_initloop
LWS_VISIBLE LWS_EXTERN int
libwebsocket_initloop(struct libwebsocket_context *context, struct ev_loop *loop)
libwebsocket_initloop(struct lws_context *context, struct ev_loop *loop)
{
return lws_initloop(context, loop);
}
@ -1023,22 +1025,22 @@ libwebsocket_sigint_cb(
#undef libwebsocket_service_fd
LWS_VISIBLE LWS_EXTERN int
libwebsocket_service_fd(struct libwebsocket_context *context,
struct libwebsocket_pollfd *pollfd)
libwebsocket_service_fd(struct lws_context *context,
struct lws_pollfd *pollfd)
{
return lws_service_fd(context, pollfd);
}
#undef libwebsocket_context_user
#undef lws_context_user
LWS_VISIBLE LWS_EXTERN void *
libwebsocket_context_user(struct libwebsocket_context *context)
libwebsocket_context_user(struct lws_context *context)
{
return lws_context_user(context);
}
#undef libwebsocket_set_timeout
LWS_VISIBLE LWS_EXTERN void
libwebsocket_set_timeout(struct libwebsocket *wsi,
libwebsocket_set_timeout(struct lws *wsi,
enum pending_timeout reason, int secs)
{
lws_set_timeout(wsi, reason, secs);
@ -1046,7 +1048,7 @@ libwebsocket_set_timeout(struct libwebsocket *wsi,
#undef libwebsocket_write
LWS_VISIBLE LWS_EXTERN int
libwebsocket_write(struct libwebsocket *wsi, unsigned char *buf, size_t len,
libwebsocket_write(struct lws *wsi, unsigned char *buf, size_t len,
enum lws_write_protocol protocol)
{
return lws_write(wsi, buf, len, protocol);
@ -1054,16 +1056,16 @@ libwebsocket_write(struct libwebsocket *wsi, unsigned char *buf, size_t len,
#undef libwebsockets_serve_http_file_fragment
LWS_VISIBLE LWS_EXTERN int
libwebsockets_serve_http_file_fragment(struct libwebsocket_context *context,
struct libwebsocket *wsi)
libwebsockets_serve_http_file_fragment(struct lws_context *context,
struct lws *wsi)
{
return lws_serve_http_file_fragment(context, wsi);
}
#undef libwebsockets_serve_http_file
LWS_VISIBLE LWS_EXTERN int
libwebsockets_serve_http_file(struct libwebsocket_context *context,
struct libwebsocket *wsi, const char *file,
libwebsockets_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)
{
@ -1074,16 +1076,16 @@ libwebsockets_serve_http_file(struct libwebsocket_context *context,
#undef libwebsockets_return_http_status
LWS_VISIBLE LWS_EXTERN int
libwebsockets_return_http_status(
struct libwebsocket_context *context,
struct libwebsocket *wsi, unsigned int code,
struct lws_context *context,
struct lws *wsi, unsigned int code,
const char *html_body)
{
return lws_return_http_status(context, wsi, code, html_body);
}
#undef libwebsockets_get_protocol
LWS_VISIBLE LWS_EXTERN const struct libwebsocket_protocols *
libwebsockets_get_protocol(struct libwebsocket *wsi)
LWS_VISIBLE LWS_EXTERN const struct lws_protocols *
libwebsockets_get_protocol(struct lws *wsi)
{
return lws_get_protocol(wsi);
}
@ -1091,15 +1093,15 @@ libwebsockets_get_protocol(struct libwebsocket *wsi)
#undef libwebsocket_callback_on_writable_all_protocol
LWS_VISIBLE LWS_EXTERN int
libwebsocket_callback_on_writable_all_protocol(
const struct libwebsocket_protocols *protocol)
const struct lws_protocols *protocol)
{
return lws_callback_on_writable_all_protocol(protocol);
}
#undef libwebsocket_callback_on_writable
LWS_VISIBLE LWS_EXTERN int
libwebsocket_callback_on_writable(struct libwebsocket_context *context,
struct libwebsocket *wsi)
libwebsocket_callback_on_writable(struct lws_context *context,
struct lws *wsi)
{
return lws_callback_on_writable(context, wsi);
}
@ -1107,56 +1109,56 @@ libwebsocket_callback_on_writable(struct libwebsocket_context *context,
#undef libwebsocket_callback_all_protocol
LWS_VISIBLE LWS_EXTERN int
libwebsocket_callback_all_protocol(
const struct libwebsocket_protocols *protocol, int reason)
const struct lws_protocols *protocol, int reason)
{
return lws_callback_all_protocol(protocol, reason);
}
#undef libwebsocket_get_socket_fd
LWS_VISIBLE LWS_EXTERN int
libwebsocket_get_socket_fd(struct libwebsocket *wsi)
libwebsocket_get_socket_fd(struct lws *wsi)
{
return lws_get_socket_fd(wsi);
}
#undef libwebsocket_is_final_fragment
LWS_VISIBLE LWS_EXTERN int
libwebsocket_is_final_fragment(struct libwebsocket *wsi)
libwebsocket_is_final_fragment(struct lws *wsi)
{
return lws_is_final_fragment(wsi);
}
#undef libwebsocket_get_reserved_bits
LWS_VISIBLE LWS_EXTERN unsigned char
libwebsocket_get_reserved_bits(struct libwebsocket *wsi)
libwebsocket_get_reserved_bits(struct lws *wsi)
{
return lws_get_reserved_bits(wsi);
}
#undef libwebsocket_rx_flow_control
LWS_VISIBLE LWS_EXTERN int
libwebsocket_rx_flow_control(struct libwebsocket *wsi, int enable)
libwebsocket_rx_flow_control(struct lws *wsi, int enable)
{
return lws_rx_flow_control(wsi, enable);
}
#undef libwebsocket_rx_flow_allow_all_protocol
LWS_VISIBLE LWS_EXTERN void
libwebsocket_rx_flow_allow_all_protocol(const struct libwebsocket_protocols *protocol)
libwebsocket_rx_flow_allow_all_protocol(const struct lws_protocols *protocol)
{
lws_rx_flow_allow_all_protocol(protocol);
}
#undef libwebsockets_remaining_packet_payload
LWS_VISIBLE LWS_EXTERN size_t
libwebsockets_remaining_packet_payload(struct libwebsocket *wsi)
libwebsockets_remaining_packet_payload(struct lws *wsi)
{
return lws_remaining_packet_payload(wsi);
}
#undef libwebsocket_client_connect
LWS_VISIBLE LWS_EXTERN struct libwebsocket *
libwebsocket_client_connect(struct libwebsocket_context *clients,
LWS_VISIBLE LWS_EXTERN struct lws *
libwebsocket_client_connect(struct lws_context *clients,
const char *address,
int port,
int ssl_connection,
@ -1169,8 +1171,8 @@ libwebsocket_client_connect(struct libwebsocket_context *clients,
return lws_client_connect(clients, address, port, ssl_connection,
path, host, origin, protocol, ietf_version_or_minus_one);
}
LWS_VISIBLE LWS_EXTERN struct libwebsocket *
libwebsocket_client_connect_extended(struct libwebsocket_context *clients,
LWS_VISIBLE LWS_EXTERN struct lws *
libwebsocket_client_connect_extended(struct lws_context *clients,
const char *address,
int port,
int ssl_connection,
@ -1187,15 +1189,15 @@ libwebsocket_client_connect_extended(struct libwebsocket_context *clients,
#undef libwebsocket_canonical_hostname
LWS_VISIBLE LWS_EXTERN const char *
libwebsocket_canonical_hostname(struct libwebsocket_context *context)
libwebsocket_canonical_hostname(struct lws_context *context)
{
return lws_canonical_hostname(context);
}
#undef libwebsockets_get_peer_addresses
LWS_VISIBLE LWS_EXTERN void
libwebsockets_get_peer_addresses(struct libwebsocket_context *context,
struct libwebsocket *wsi, lws_sockfd_type fd, char *name,
libwebsockets_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_get_peer_addresses(context, wsi, fd, name, name_len, rip, rip_len);
@ -1203,7 +1205,7 @@ libwebsockets_get_peer_addresses(struct libwebsocket_context *context,
#undef libwebsockets_get_random
LWS_VISIBLE LWS_EXTERN int
libwebsockets_get_random(struct libwebsocket_context *context, void *buf, int len)
libwebsockets_get_random(struct lws_context *context, void *buf, int len)
{
return lws_get_random(context, buf, len);
}
@ -1219,7 +1221,7 @@ libwebsockets_SHA1(const unsigned char *d, size_t n, unsigned char *md)
#undef libwebsocket_read
LWS_VISIBLE LWS_EXTERN int
libwebsocket_read(struct libwebsocket_context *context, struct libwebsocket *wsi,
libwebsocket_read(struct lws_context *context, struct lws *wsi,
unsigned char *buf, size_t len)
{
return lws_read(context, wsi, buf, len);
@ -1227,7 +1229,7 @@ libwebsocket_read(struct libwebsocket_context *context, struct libwebsocket *wsi
#ifndef LWS_NO_EXTENSIONS
#undef libwebsocket_get_internal_extensions
LWS_VISIBLE LWS_EXTERN struct libwebsocket_extension *
LWS_VISIBLE LWS_EXTERN struct lws_extension *
libwebsocket_get_internal_extensions()
{
return lws_get_internal_extensions();

View file

@ -26,14 +26,14 @@
#define libwebsocket_create_context lws_create_context
#define libwebsocket_set_proxy lws_set_proxy
#define libwebsocket_context_destroy lws_context_destroy
#define lws_context_destroy lws_context_destroy
#define libwebsocket_service lws_service
#define libwebsocket_cancel_service lws_cancel_service
#define libwebsocket_sigint_cfg lws_sigint_cfg
#define libwebsocket_initloop lws_initloop
#define libwebsocket_sigint_cb lws_sigint_cb
#define libwebsocket_service_fd lws_service_fd
#define libwebsocket_context_user lws_context_user
#define lws_context_user lws_context_user
#define libwebsocket_set_timeout lws_set_timeout
#define libwebsocket_write lws_write
#define libwebsockets_serve_http_file_fragment lws_serve_http_file_fragment
@ -58,6 +58,13 @@
#define libwebsocket_get_internal_extensions lws_get_internal_extensions
#define libwebsocket_write_protocol lws_write_protocol
#define libwebsocket_protocols lws_protocols
#define libwebsocket_extension lws_extension
#define libwebsocket_context lws_context
#define libwebsocket_pollfd lws_pollfd
#define lws_callback_reasons lws_callback_reasons
#define libwebsocket lws
#ifdef __cplusplus
#include <cstddef>
#include <cstdarg>
@ -73,8 +80,8 @@ namespace {
}
using namespace mbed::Sockets::v0;
struct libwebsocket;
struct libwebsocket_context;
struct lws;
struct lws_context;
class lws_conn {
public:
@ -87,19 +94,19 @@ class lws_conn {
}
public:
void set_wsi(struct libwebsocket *_wsi) { wsi = _wsi; }
void set_wsi(struct lws *_wsi) { wsi = _wsi; }
int actual_onRX(Socket *s);
void onRX(Socket *s);
void onError(Socket *s, socket_error_t err);
void onDisconnect(TCPStream *s);
void onSent(Socket *s, uint16_t len);
void serialized_writeable(struct libwebsocket *wsi);
void serialized_writeable(struct lws *wsi);
public:
TCPStream *ts;
public:
struct libwebsocket *wsi;
struct lws *wsi;
char buffer[BUFFER_SIZE];
char writeable;
char awaiting_on_writeable;
@ -280,7 +287,7 @@ LWS_VISIBLE LWS_EXTERN void lwsl_hexdump(void *buf, size_t len);
#define LWS_FEATURE_SERVE_HTTP_FILE_HAS_OTHER_HEADERS_ARG
/* the struct libwebsocket_protocols has the id field present */
/* the struct lws_protocols has the id field present */
#define LWS_FEATURE_PROTOCOLS_HAS_ID_FIELD
/* you can call lws_get_peer_write_allowance */
@ -289,7 +296,7 @@ LWS_VISIBLE LWS_EXTERN void lwsl_hexdump(void *buf, size_t len);
/* extra parameter introduced in 917f43ab821 */
#define LWS_FEATURE_SERVE_HTTP_FILE_HAS_OTHER_HEADERS_LEN
enum libwebsocket_context_options {
enum lws_context_options {
LWS_SERVER_OPTION_REQUIRE_VALID_OPENSSL_CLIENT_CERT = 2,
LWS_SERVER_OPTION_SKIP_SERVER_CANONICAL_NAME = 4,
LWS_SERVER_OPTION_ALLOW_NON_SSL_ON_SSL_PORT = 8,
@ -299,7 +306,7 @@ enum libwebsocket_context_options {
LWS_SERVER_OPTION_PEER_CERT_NOT_REQUIRED = 128,
};
enum libwebsocket_callback_reasons {
enum lws_callback_reasons {
LWS_CALLBACK_ESTABLISHED,
LWS_CALLBACK_CLIENT_CONNECTION_ERROR,
LWS_CALLBACK_CLIENT_FILTER_PRE_ESTABLISH,
@ -349,12 +356,12 @@ enum libwebsocket_callback_reasons {
#if defined(_WIN32) && (_WIN32_WINNT < 0x0600)
typedef SOCKET lws_sockfd_type;
#define lws_sockfd_valid(sfd) (!!sfd)
struct libwebsocket_pollfd {
struct lws_pollfd {
lws_sockfd_type fd;
SHORT events;
SHORT revents;
};
WINSOCK_API_LINKAGE int WSAAPI WSAPoll(struct libwebsocket_pollfd fdArray[], ULONG fds, INT timeout);
WINSOCK_API_LINKAGE int WSAAPI WSAPoll(struct lws_pollfd fdArray[], ULONG fds, INT timeout);
#else
#if defined(MBED_OPERATORS)
@ -373,29 +380,29 @@ struct pollfd {
#define POLLHUP 0x0010
#define POLLNVAL 0x0020
struct libwebsocket;
struct lws;
void * mbed3_create_tcp_stream_socket(void);
void mbed3_delete_tcp_stream_socket(void *sockfd);
void mbed3_tcp_stream_bind(void *sock, int port, struct libwebsocket *);
void mbed3_tcp_stream_accept(void *sock, struct libwebsocket *);
void mbed3_tcp_stream_bind(void *sock, int port, struct lws *);
void mbed3_tcp_stream_accept(void *sock, struct lws *);
#else
typedef int lws_sockfd_type;
#define lws_sockfd_valid(sfd) (sfd >= 0)
#endif
#define libwebsocket_pollfd pollfd
#define lws_pollfd pollfd
#endif
// argument structure for all external poll related calls
// passed in via 'in'
struct libwebsocket_pollargs {
struct lws_pollargs {
lws_sockfd_type fd; // applicable file descriptor
int events; // the new event mask
int prev_events; // the previous event mask
};
enum libwebsocket_extension_callback_reasons {
enum lws_extension_callback_reasons {
LWS_EXT_CALLBACK_SERVER_CONTEXT_CONSTRUCT,
LWS_EXT_CALLBACK_CLIENT_CONTEXT_CONSTRUCT,
LWS_EXT_CALLBACK_SERVER_CONTEXT_DESTRUCT,
@ -714,10 +721,10 @@ enum http_status {
HTTP_STATUS_HTTP_VERSION_NOT_SUPPORTED,
};
struct libwebsocket;
struct libwebsocket_context;
struct lws;
struct lws_context;
/* needed even with extensions disabled for create context */
struct libwebsocket_extension;
struct lws_extension;
/**
* callback_function() - User server actions
@ -733,7 +740,7 @@ struct libwebsocket_extension;
*
* For each connection / session there is user data allocated that is
* pointed to by "user". You set the size of this user data area when
* the library is initialized with libwebsocket_create_server.
* the library is initialized with lws_create_server.
*
* You get an opportunity to initialize user data when called back with
* LWS_CALLBACK_ESTABLISHED reason.
@ -956,7 +963,7 @@ struct libwebsocket_extension;
* will be integrating libwebsockets sockets into an external polling
* array.
*
* For these calls, @in points to a struct libwebsocket_pollargs that
* For these calls, @in points to a struct lws_pollargs that
* contains @fd, @events and @prev_events members
*
* LWS_CALLBACK_ADD_POLL_FD: libwebsocket deals with its poll() loop
@ -969,7 +976,7 @@ struct libwebsocket_extension;
* serving case.
* This callback happens when a socket needs to be
* added to the polling loop: @in points to a struct
* libwebsocket_pollargs; the @fd member of the struct is the file
* lws_pollargs; the @fd member of the struct is the file
* descriptor, and @events contains the active events.
*
* If you are using the internal polling loop (the "service"
@ -977,13 +984,13 @@ struct libwebsocket_extension;
*
* LWS_CALLBACK_DEL_POLL_FD: This callback happens when a socket descriptor
* needs to be removed from an external polling array. @in is
* again the struct libwebsocket_pollargs containing the @fd member
* again the struct lws_pollargs containing the @fd member
* to be removed. If you are using the internal polling
* loop, you can just ignore it.
*
* LWS_CALLBACK_CHANGE_MODE_POLL_FD: This callback happens when
* libwebsockets wants to modify the events for a connectiion.
* @in is the struct libwebsocket_pollargs with the @fd to change.
* @in is the struct lws_pollargs with the @fd to change.
* The new event mask is in @events member and the old mask is in
* the @prev_events member.
* If you are using the internal polling loop, you can just ignore
@ -1002,14 +1009,14 @@ struct libwebsocket_extension;
* wsi lifecycle changes if it acquires the same lock for the
* duration of wsi dereference from the other thread context.
*/
LWS_VISIBLE LWS_EXTERN int callback(struct libwebsocket_context *context,
struct libwebsocket *wsi,
enum libwebsocket_callback_reasons reason, void *user,
LWS_VISIBLE LWS_EXTERN int callback(struct lws_context *context,
struct lws *wsi,
enum lws_callback_reasons reason, void *user,
void *in, size_t len);
typedef int (callback_function)(struct libwebsocket_context *context,
struct libwebsocket *wsi,
enum libwebsocket_callback_reasons reason, void *user,
typedef int (callback_function)(struct lws_context *context,
struct lws *wsi,
enum lws_callback_reasons reason, void *user,
void *in, size_t len);
#ifndef LWS_NO_EXTENSIONS
@ -1071,21 +1078,21 @@ typedef int (callback_function)(struct libwebsocket_context *context,
* buffer safely, it should copy the data into its own buffer and
* set the lws_tokens token pointer to it.
*/
LWS_VISIBLE LWS_EXTERN int extension_callback(struct libwebsocket_context *context,
struct libwebsocket_extension *ext,
struct libwebsocket *wsi,
enum libwebsocket_extension_callback_reasons reason,
LWS_VISIBLE LWS_EXTERN int extension_callback(struct lws_context *context,
struct lws_extension *ext,
struct lws *wsi,
enum lws_extension_callback_reasons reason,
void *user, void *in, size_t len);
typedef int (extension_callback_function)(struct libwebsocket_context *context,
struct libwebsocket_extension *ext,
struct libwebsocket *wsi,
enum libwebsocket_extension_callback_reasons reason,
typedef int (extension_callback_function)(struct lws_context *context,
struct lws_extension *ext,
struct lws *wsi,
enum lws_extension_callback_reasons reason,
void *user, void *in, size_t len);
#endif
/**
* struct libwebsocket_protocols - List of protocols and handlers server
* struct lws_protocols - List of protocols and handlers server
* supports.
* @name: Protocol name that must match the one given in the client
* Javascript new WebSocket(url, 'protocol') name.
@ -1119,7 +1126,7 @@ typedef int (extension_callback_function)(struct libwebsocket_context *context,
* @protocol_index: which protocol we are starting from zero
*
* This structure represents one protocol supported by the server. An
* array of these structures is passed to libwebsocket_create_server()
* array of these structures is passed to lws_create_server()
* allows as many protocols as you like to be handled by one server.
*
* The first protocol given has its callback used for user callbacks when
@ -1127,7 +1134,7 @@ typedef int (extension_callback_function)(struct libwebsocket_context *context,
* connection and true if the client did not send a Protocol: header.
*/
struct libwebsocket_protocols {
struct lws_protocols {
const char *name;
callback_function *callback;
size_t per_session_data_size;
@ -1140,13 +1147,13 @@ struct libwebsocket_protocols {
* no need for user to use them directly either
*/
struct libwebsocket_context *owning_server;
struct lws_context *owning_server;
int protocol_index;
};
#ifndef LWS_NO_EXTENSIONS
/**
* struct libwebsocket_extension - An extension we know how to cope with
* struct lws_extension - An extension we know how to cope with
*
* @name: Formal extension name, eg, "deflate-stream"
* @callback: Service callback
@ -1158,7 +1165,7 @@ struct libwebsocket_protocols {
* all sessions, etc, if it wants
*/
struct libwebsocket_extension {
struct lws_extension {
const char *name;
extension_callback_function *callback;
size_t per_session_data_size;
@ -1179,7 +1186,7 @@ struct libwebsocket_extension {
* specific callback for each one. The list is ended with an
* entry that has a NULL callback pointer.
* It's not const because we write the owning_server member
* @extensions: NULL or array of libwebsocket_extension structs listing the
* @extensions: NULL or array of lws_extension structs listing the
* extensions this context supports. If you configured with
* --without-extensions, you should give NULL here.
* @token_limits: NULL or struct lws_token_limits pointer which is initialized
@ -1220,8 +1227,8 @@ struct libwebsocket_extension {
struct lws_context_creation_info {
int port;
const char *iface;
struct libwebsocket_protocols *protocols;
struct libwebsocket_extension *extensions;
struct lws_protocols *protocols;
struct lws_extension *extensions;
struct lws_token_limits *token_limits;
const char *ssl_private_key_password;
const char *ssl_cert_filepath;
@ -1251,72 +1258,72 @@ void lws_set_log_level(int level,
LWS_VISIBLE LWS_EXTERN void
lwsl_emit_syslog(int level, const char *line);
LWS_VISIBLE LWS_EXTERN struct libwebsocket_context *
LWS_VISIBLE LWS_EXTERN struct lws_context *
lws_create_context(struct lws_context_creation_info *info);
LWS_VISIBLE LWS_EXTERN int
lws_set_proxy(struct libwebsocket_context *context, const char *proxy);
lws_set_proxy(struct lws_context *context, const char *proxy);
LWS_VISIBLE LWS_EXTERN void
lws_context_destroy(struct libwebsocket_context *context);
lws_context_destroy(struct lws_context *context);
LWS_VISIBLE LWS_EXTERN int
lws_service(struct libwebsocket_context *context, int timeout_ms);
lws_service(struct lws_context *context, int timeout_ms);
LWS_VISIBLE LWS_EXTERN void
lws_cancel_service(struct libwebsocket_context *context);
lws_cancel_service(struct lws_context *context);
LWS_VISIBLE LWS_EXTERN const unsigned char *
lws_token_to_string(enum lws_token_indexes token);
LWS_VISIBLE LWS_EXTERN int
lws_add_http_header_by_name(struct libwebsocket_context *context,
struct libwebsocket *wsi,
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 libwebsocket_context *context,
struct libwebsocket *wsi,
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 libwebsocket_context *context,
struct libwebsocket *wsi,
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 libwebsocket_context *context,
struct libwebsocket *wsi,
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 libwebsocket_context *context,
struct libwebsocket *wsi,
lws_add_http_header_status(struct lws_context *context,
struct lws *wsi,
unsigned int code,
unsigned char **p,
unsigned char *end);
LWS_EXTERN int lws_http_transaction_completed(struct libwebsocket *wsi);
LWS_EXTERN int lws_http_transaction_completed(struct lws *wsi);
#ifdef LWS_USE_LIBEV
typedef void (lws_ev_signal_cb)(EV_P_ struct ev_signal *w, int revents);
LWS_VISIBLE LWS_EXTERN int
lws_sigint_cfg(
struct libwebsocket_context *context,
struct lws_context *context,
int use_ev_sigint,
lws_ev_signal_cb* cb);
LWS_VISIBLE LWS_EXTERN int
lws_initloop(
struct libwebsocket_context *context, struct ev_loop *loop);
struct lws_context *context, struct ev_loop *loop);
LWS_VISIBLE void
lws_sigint_cb(
@ -1324,11 +1331,11 @@ lws_sigint_cb(
#endif /* LWS_USE_LIBEV */
LWS_VISIBLE LWS_EXTERN int
lws_service_fd(struct libwebsocket_context *context,
struct libwebsocket_pollfd *pollfd);
lws_service_fd(struct lws_context *context,
struct lws_pollfd *pollfd);
LWS_VISIBLE LWS_EXTERN void *
lws_context_user(struct libwebsocket_context *context);
lws_context_user(struct lws_context *context);
enum pending_timeout {
NO_PENDING_TIMEOUT = 0,
@ -1347,7 +1354,7 @@ enum pending_timeout {
};
LWS_VISIBLE LWS_EXTERN void
lws_set_timeout(struct libwebsocket *wsi,
lws_set_timeout(struct lws *wsi,
enum pending_timeout reason, int secs);
/*
@ -1408,7 +1415,7 @@ lws_set_timeout(struct libwebsocket *wsi,
#define LWS_SEND_BUFFER_POST_PADDING 4
LWS_VISIBLE LWS_EXTERN int
lws_write(struct libwebsocket *wsi, unsigned char *buf, size_t len,
lws_write(struct lws *wsi, unsigned char *buf, size_t len,
enum lws_write_protocol protocol);
/* helper for case where buffer may be const */
@ -1416,51 +1423,48 @@ lws_write(struct libwebsocket *wsi, unsigned char *buf, size_t len,
lws_write(wsi, (unsigned char *)(buf), len, LWS_WRITE_HTTP)
LWS_VISIBLE LWS_EXTERN int
lws_serve_http_file(struct libwebsocket_context *context,
struct libwebsocket *wsi, const char *file,
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 libwebsocket_context *context,
struct libwebsocket *wsi);
LWS_VISIBLE LWS_EXTERN int lws_return_http_status(
struct libwebsocket_context *context,
struct libwebsocket *wsi, unsigned int code,
const char *html_body);
LWS_VISIBLE LWS_EXTERN const struct libwebsocket_protocols *
lws_get_protocol(struct libwebsocket *wsi);
lws_serve_http_file_fragment(struct lws_context *context,
struct lws *wsi);
LWS_VISIBLE LWS_EXTERN int
lws_callback_on_writable(struct libwebsocket_context *context,
struct libwebsocket *wsi);
lws_return_http_status(struct lws_context *context,
struct lws *wsi, unsigned int code,
const char *html_body);
LWS_VISIBLE LWS_EXTERN const struct lws_protocols *
lws_get_protocol(struct lws *wsi);
LWS_VISIBLE LWS_EXTERN int
lws_callback_on_writable_all_protocol(
const struct libwebsocket_protocols *protocol);
lws_callback_on_writable(struct lws_context *context, struct lws *wsi);
LWS_VISIBLE LWS_EXTERN int
lws_callback_all_protocol(
const struct libwebsocket_protocols *protocol, int reason);
lws_callback_on_writable_all_protocol(const struct lws_protocols *protocol);
LWS_VISIBLE LWS_EXTERN int
lws_get_socket_fd(struct libwebsocket *wsi);
lws_callback_all_protocol(const struct lws_protocols *protocol, int reason);
LWS_VISIBLE LWS_EXTERN int
lws_is_final_fragment(struct libwebsocket *wsi);
lws_get_socket_fd(struct lws *wsi);
LWS_VISIBLE LWS_EXTERN int
lws_is_final_fragment(struct lws *wsi);
LWS_VISIBLE LWS_EXTERN unsigned char
lws_get_reserved_bits(struct libwebsocket *wsi);
lws_get_reserved_bits(struct lws *wsi);
LWS_VISIBLE LWS_EXTERN int
lws_rx_flow_control(struct libwebsocket *wsi, int enable);
lws_rx_flow_control(struct lws *wsi, int enable);
LWS_VISIBLE LWS_EXTERN void
lws_rx_flow_allow_all_protocol(const struct libwebsocket_protocols *protocol);
lws_rx_flow_allow_all_protocol(const struct lws_protocols *protocol);
LWS_VISIBLE LWS_EXTERN size_t
lws_remaining_packet_payload(struct libwebsocket *wsi);
lws_remaining_packet_payload(struct lws *wsi);
/*
* if the protocol does not have any guidance, returns -1. Currently only
@ -1479,10 +1483,10 @@ lws_remaining_packet_payload(struct libwebsocket *wsi);
* intermediary dynamically.
*/
LWS_VISIBLE LWS_EXTERN size_t
lws_get_peer_write_allowance(struct libwebsocket *wsi);
lws_get_peer_write_allowance(struct lws *wsi);
LWS_VISIBLE LWS_EXTERN struct libwebsocket *
lws_client_connect(struct libwebsocket_context *clients,
LWS_VISIBLE LWS_EXTERN struct lws *
lws_client_connect(struct lws_context *clients,
const char *address,
int port,
int ssl_connection,
@ -1492,8 +1496,8 @@ lws_client_connect(struct libwebsocket_context *clients,
const char *protocol,
int ietf_version_or_minus_one);
LWS_VISIBLE LWS_EXTERN struct libwebsocket *
lws_client_connect_extended(struct libwebsocket_context *clients,
LWS_VISIBLE LWS_EXTERN struct lws *
lws_client_connect_extended(struct lws_context *clients,
const char *address,
int port,
int ssl_connection,
@ -1505,32 +1509,32 @@ lws_client_connect_extended(struct libwebsocket_context *clients,
void *userdata);
LWS_VISIBLE LWS_EXTERN const char *
lws_canonical_hostname(struct libwebsocket_context *context);
lws_canonical_hostname(struct lws_context *context);
LWS_VISIBLE LWS_EXTERN void
lws_get_peer_addresses(struct libwebsocket_context *context,
struct libwebsocket *wsi, lws_sockfd_type fd,
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_get_random(struct libwebsocket_context *context, void *buf, int len);
lws_get_random(struct lws_context *context, void *buf, int len);
LWS_VISIBLE LWS_EXTERN int
lws_daemonize(const char *_lock_path);
LWS_VISIBLE LWS_EXTERN int
lws_send_pipe_choked(struct libwebsocket *wsi);
lws_send_pipe_choked(struct lws *wsi);
LWS_VISIBLE LWS_EXTERN int
lws_partial_buffered(struct libwebsocket *wsi);
lws_partial_buffered(struct lws *wsi);
LWS_VISIBLE LWS_EXTERN int
lws_frame_is_binary(struct libwebsocket *wsi);
lws_frame_is_binary(struct lws *wsi);
LWS_VISIBLE LWS_EXTERN int
lws_is_ssl(struct libwebsocket *wsi);
lws_is_ssl(struct lws *wsi);
#ifdef LWS_SHA1_USE_OPENSSL_NAME
#define lws_SHA1 SHA1
#else
@ -1550,10 +1554,10 @@ lws_get_library_version(void);
/* access to headers... only valid while headers valid */
LWS_VISIBLE LWS_EXTERN int
lws_hdr_total_length(struct libwebsocket *wsi, enum lws_token_indexes h);
lws_hdr_total_length(struct lws *wsi, enum lws_token_indexes h);
LWS_VISIBLE LWS_EXTERN int
lws_hdr_copy(struct libwebsocket *wsi, char *dest, int len,
lws_hdr_copy(struct lws *wsi, char *dest, int len,
enum lws_token_indexes h);
/*
@ -1562,12 +1566,11 @@ lws_hdr_copy(struct libwebsocket *wsi, char *dest, int len,
*/
LWS_VISIBLE LWS_EXTERN int
lws_read(struct libwebsocket_context *context,
struct libwebsocket *wsi,
unsigned char *buf, size_t len);
lws_read(struct lws_context *context, struct lws *wsi,
unsigned char *buf, size_t len);
#ifndef LWS_NO_EXTENSIONS
LWS_VISIBLE LWS_EXTERN struct libwebsocket_extension *lws_get_internal_extensions();
LWS_VISIBLE LWS_EXTERN struct lws_extension *lws_get_internal_extensions();
#endif
/*

View file

@ -12,7 +12,7 @@ unsigned long long time_in_microseconds(void)
return 0;
}
LWS_VISIBLE int lws_get_random(struct libwebsocket_context *context,
LWS_VISIBLE int lws_get_random(struct lws_context *context,
void *buf, int len)
{
(void)context;
@ -38,10 +38,10 @@ LWS_VISIBLE int lws_get_random(struct libwebsocket_context *context,
* get their turn at the network device.
*/
LWS_VISIBLE int lws_send_pipe_choked(struct libwebsocket *wsi)
LWS_VISIBLE int lws_send_pipe_choked(struct lws *wsi)
{
#if 0
struct libwebsocket_pollfd fds;
struct lws_pollfd fds;
/* treat the fact we got a truncated send pending as if we're choked */
if (wsi->truncated_send_len)
@ -64,7 +64,7 @@ LWS_VISIBLE int lws_send_pipe_choked(struct libwebsocket *wsi)
}
LWS_VISIBLE int
lws_poll_listen_fd(struct libwebsocket_pollfd *fd)
lws_poll_listen_fd(struct lws_pollfd *fd)
{
(void)fd;
return -1;
@ -81,7 +81,7 @@ lws_poll_listen_fd(struct libwebsocket_pollfd *fd)
* it.
*/
LWS_VISIBLE void
lws_cancel_service(struct libwebsocket_context *context)
lws_cancel_service(struct lws_context *context)
{
(void)context;
}
@ -92,7 +92,7 @@ LWS_VISIBLE void lwsl_emit_syslog(int level, const char *line)
}
LWS_VISIBLE int
lws_plat_set_socket_options(struct libwebsocket_context *context, lws_sockfd_type fd)
lws_plat_set_socket_options(struct lws_context *context, lws_sockfd_type fd)
{
(void)context;
(void)fd;
@ -106,14 +106,14 @@ lws_plat_drop_app_privileges(struct lws_context_creation_info *info)
}
LWS_VISIBLE int
lws_plat_init_lookup(struct libwebsocket_context *context)
lws_plat_init_lookup(struct lws_context *context)
{
(void)context;
return 0;
}
LWS_VISIBLE int
lws_plat_init_fd_tables(struct libwebsocket_context *context)
lws_plat_init_fd_tables(struct lws_context *context)
{
(void)context;
return 0;
@ -127,20 +127,20 @@ lws_plat_context_early_init(void)
}
LWS_VISIBLE void
lws_plat_context_early_destroy(struct libwebsocket_context *context)
lws_plat_context_early_destroy(struct lws_context *context)
{
(void)context;
}
LWS_VISIBLE void
lws_plat_context_late_destroy(struct libwebsocket_context *context)
lws_plat_context_late_destroy(struct lws_context *context)
{
(void)context;
}
LWS_VISIBLE void
lws_plat_service_periodic(struct libwebsocket_context *context)
lws_plat_service_periodic(struct lws_context *context)
{
(void)context;
}
@ -164,7 +164,7 @@ lws_plat_inet_ntop(int af, const void *src, char *dst, int cnt)
}
LWS_VISIBLE int
insert_wsi(struct libwebsocket_context *context, struct libwebsocket *wsi)
insert_wsi(struct lws_context *context, struct lws *wsi)
{
(void)context;
(void)wsi;
@ -173,7 +173,7 @@ insert_wsi(struct libwebsocket_context *context, struct libwebsocket *wsi)
}
LWS_VISIBLE int
delete_from_fd(struct libwebsocket_context *context, lws_sockfd_type fd)
delete_from_fd(struct lws_context *context, lws_sockfd_type fd)
{
(void)context;
(void)fd;

View file

@ -21,10 +21,10 @@ extern "C" void mbed3_delete_tcp_stream_socket(void *sock)
delete conn;
}
void lws_conn::serialized_writeable(struct libwebsocket *_wsi)
void lws_conn::serialized_writeable(struct lws *_wsi)
{
struct libwebsocket *wsi = (struct libwebsocket *)_wsi;
struct libwebsocket_pollfd pollfd;
struct lws *wsi = (struct lws *)_wsi;
struct lws_pollfd pollfd;
lws_conn *conn = (lws_conn *)wsi->sock;
conn->awaiting_on_writeable = 0;
@ -38,7 +38,7 @@ void lws_conn::serialized_writeable(struct libwebsocket *_wsi)
lws_service_fd(wsi->protocol->owning_server, &pollfd);
}
extern "C" void mbed3_tcp_stream_bind(void *sock, int port, struct libwebsocket *wsi)
extern "C" void mbed3_tcp_stream_bind(void *sock, int port, struct lws *wsi)
{
lws_conn_listener *srv = (lws_conn_listener *)sock;
@ -50,7 +50,7 @@ extern "C" void mbed3_tcp_stream_bind(void *sock, int port, struct libwebsocket
minar::Scheduler::postCallback(fp.bind(port));
}
extern "C" void mbed3_tcp_stream_accept(void *sock, struct libwebsocket *wsi)
extern "C" void mbed3_tcp_stream_accept(void *sock, struct lws *wsi)
{
lws_conn *conn = (lws_conn *)sock;
@ -59,8 +59,8 @@ extern "C" void mbed3_tcp_stream_accept(void *sock, struct libwebsocket *wsi)
}
extern "C" LWS_VISIBLE int
lws_plat_change_pollfd(struct libwebsocket_context *context,
struct libwebsocket *wsi, struct libwebsocket_pollfd *pfd)
lws_plat_change_pollfd(struct lws_context *context,
struct lws *wsi, struct lws_pollfd *pfd)
{
lws_conn *conn = (lws_conn *)wsi->sock;
@ -68,7 +68,7 @@ lws_plat_change_pollfd(struct libwebsocket_context *context,
if (pfd->events & POLLOUT) {
conn->awaiting_on_writeable = 1;
if (conn->writeable) {
mbed::util::FunctionPointer1<void, struct libwebsocket *> book(conn, &lws_conn::serialized_writeable);
mbed::util::FunctionPointer1<void, struct lws *> book(conn, &lws_conn::serialized_writeable);
minar::Scheduler::postCallback(book.bind(wsi));
lwsl_debug("%s: wsi %p (booked callback)\r\n", __func__, (void *)wsi);
} else {
@ -82,8 +82,8 @@ lws_plat_change_pollfd(struct libwebsocket_context *context,
}
extern "C" LWS_VISIBLE int
lws_ssl_capable_read_no_ssl(struct libwebsocket_context *context,
struct libwebsocket *wsi, unsigned char *buf, int len)
lws_ssl_capable_read_no_ssl(struct lws_context *context,
struct lws *wsi, unsigned char *buf, int len)
{
socket_error_t err;
size_t _len = len;
@ -110,7 +110,7 @@ lws_ssl_capable_read_no_ssl(struct libwebsocket_context *context,
}
extern "C" LWS_VISIBLE int
lws_ssl_capable_write_no_ssl(struct libwebsocket *wsi, unsigned char *buf, int len)
lws_ssl_capable_write_no_ssl(struct lws *wsi, unsigned char *buf, int len)
{
socket_error_t err;
lws_conn *conn = (lws_conn *)wsi->sock;
@ -159,7 +159,7 @@ void lws_conn_listener::start(const uint16_t port)
int lws_conn::actual_onRX(Socket *s)
{
struct libwebsocket_pollfd pollfd;
struct lws_pollfd pollfd;
(void)s;
@ -215,8 +215,8 @@ void lws_conn_listener::onIncoming(TCPListener *tl, void *impl)
lwsl_debug("%s: exit\n", __func__);
}
extern "C" LWS_VISIBLE struct libwebsocket *
wsi_from_fd(struct libwebsocket_context *context, lws_sockfd_type fd)
extern "C" LWS_VISIBLE struct lws *
wsi_from_fd(struct lws_context *context, lws_sockfd_type fd)
{
lws_conn *conn = (lws_conn *)fd;
(void)context;
@ -225,8 +225,8 @@ wsi_from_fd(struct libwebsocket_context *context, lws_sockfd_type fd)
}
extern "C" LWS_VISIBLE void
lws_plat_insert_socket_into_fds(struct libwebsocket_context *context,
struct libwebsocket *wsi)
lws_plat_insert_socket_into_fds(struct lws_context *context,
struct lws *wsi)
{
(void)wsi;
lws_libev_io(context, wsi, LWS_EV_START | LWS_EV_READ);
@ -234,8 +234,8 @@ lws_plat_insert_socket_into_fds(struct libwebsocket_context *context,
}
extern "C" LWS_VISIBLE void
lws_plat_delete_socket_from_fds(struct libwebsocket_context *context,
struct libwebsocket *wsi, int m)
lws_plat_delete_socket_from_fds(struct lws_context *context,
struct lws *wsi, int m)
{
(void)context;
(void)wsi;
@ -256,7 +256,7 @@ void lws_conn_listener::onDisconnect(TCPStream *s)
}
extern "C" LWS_VISIBLE int
lws_plat_service(struct libwebsocket_context *context, int timeout_ms)
lws_plat_service(struct lws_context *context, int timeout_ms)
{
(void)context;
(void)timeout_ms;
@ -266,7 +266,7 @@ lws_plat_service(struct libwebsocket_context *context, int timeout_ms)
void lws_conn::onSent(Socket *s, uint16_t len)
{
struct libwebsocket_pollfd pollfd;
struct lws_pollfd pollfd;
(void)s;
(void)len;

View file

@ -14,15 +14,15 @@ unsigned long long time_in_microseconds(void)
return ((unsigned long long)tv.tv_sec * 1000000LL) + tv.tv_usec;
}
LWS_VISIBLE int lws_get_random(struct libwebsocket_context *context,
LWS_VISIBLE int lws_get_random(struct lws_context *context,
void *buf, int len)
{
return read(context->fd_random, (char *)buf, len);
}
LWS_VISIBLE int lws_send_pipe_choked(struct libwebsocket *wsi)
LWS_VISIBLE int lws_send_pipe_choked(struct lws *wsi)
{
struct libwebsocket_pollfd fds;
struct lws_pollfd fds;
/* treat the fact we got a truncated send pending as if we're choked */
if (wsi->truncated_send_len)
@ -44,7 +44,7 @@ LWS_VISIBLE int lws_send_pipe_choked(struct libwebsocket *wsi)
}
LWS_VISIBLE int
lws_poll_listen_fd(struct libwebsocket_pollfd *fd)
lws_poll_listen_fd(struct lws_pollfd *fd)
{
return poll(fd, 1, 0);
}
@ -65,7 +65,7 @@ static void lws_sigusr2(int sig)
* immediately return.
*/
LWS_VISIBLE void
lws_cancel_service(struct libwebsocket_context *context)
lws_cancel_service(struct lws_context *context)
{
char buf = 0;
@ -95,13 +95,13 @@ LWS_VISIBLE void lwsl_emit_syslog(int level, const char *line)
}
LWS_VISIBLE int
lws_plat_service(struct libwebsocket_context *context, int timeout_ms)
lws_plat_service(struct lws_context *context, int timeout_ms)
{
int n;
int m;
char buf;
#ifdef LWS_OPENSSL_SUPPORT
struct libwebsocket *wsi, *wsi_next;
struct lws *wsi, *wsi_next;
#endif
/* stay dead once we are dead */
@ -188,7 +188,7 @@ lws_plat_service(struct libwebsocket_context *context, int timeout_ms)
}
LWS_VISIBLE int
lws_plat_set_socket_options(struct libwebsocket_context *context, int fd)
lws_plat_set_socket_options(struct lws_context *context, int fd)
{
int optval = 1;
socklen_t optlen = sizeof(optval);
@ -272,9 +272,9 @@ lws_plat_drop_app_privileges(struct lws_context_creation_info *info)
}
LWS_VISIBLE int
lws_plat_init_lookup(struct libwebsocket_context *context)
lws_plat_init_lookup(struct lws_context *context)
{
context->lws_lookup = lws_zalloc(sizeof(struct libwebsocket *) * context->max_fds);
context->lws_lookup = lws_zalloc(sizeof(struct lws *) * context->max_fds);
if (context->lws_lookup == NULL) {
lwsl_err(
"Unable to allocate lws_lookup array for %d connections\n",
@ -286,7 +286,7 @@ lws_plat_init_lookup(struct libwebsocket_context *context)
}
LWS_VISIBLE int
lws_plat_init_fd_tables(struct libwebsocket_context *context)
lws_plat_init_fd_tables(struct lws_context *context)
{
context->fd_random = open(SYSTEM_RANDOM_FILEPATH, O_RDONLY);
if (context->fd_random < 0) {
@ -335,12 +335,12 @@ lws_plat_context_early_init(void)
}
LWS_VISIBLE void
lws_plat_context_early_destroy(struct libwebsocket_context *context)
lws_plat_context_early_destroy(struct lws_context *context)
{
}
LWS_VISIBLE void
lws_plat_context_late_destroy(struct libwebsocket_context *context)
lws_plat_context_late_destroy(struct lws_context *context)
{
if (context->lws_lookup)
lws_free(context->lws_lookup);
@ -353,7 +353,7 @@ lws_plat_context_late_destroy(struct libwebsocket_context *context)
/* cast a struct sockaddr_in6 * into addr for ipv6 */
LWS_VISIBLE int
interface_to_sa(struct libwebsocket_context *context,
interface_to_sa(struct lws_context *context,
const char *ifname, struct sockaddr_in *addr, size_t addrlen)
{
int rc = -1;
@ -422,21 +422,21 @@ interface_to_sa(struct libwebsocket_context *context,
}
LWS_VISIBLE void
lws_plat_insert_socket_into_fds(struct libwebsocket_context *context,
struct libwebsocket *wsi)
lws_plat_insert_socket_into_fds(struct lws_context *context,
struct lws *wsi)
{
lws_libev_io(context, wsi, LWS_EV_START | LWS_EV_READ);
context->fds[context->fds_count++].revents = 0;
}
LWS_VISIBLE void
lws_plat_delete_socket_from_fds(struct libwebsocket_context *context,
struct libwebsocket *wsi, int m)
lws_plat_delete_socket_from_fds(struct lws_context *context,
struct lws *wsi, int m)
{
}
LWS_VISIBLE void
lws_plat_service_periodic(struct libwebsocket_context *context)
lws_plat_service_periodic(struct lws_context *context)
{
/* if our parent went down, don't linger around */
if (context->started_with_parent &&
@ -445,8 +445,8 @@ lws_plat_service_periodic(struct libwebsocket_context *context)
}
LWS_VISIBLE int
lws_plat_change_pollfd(struct libwebsocket_context *context,
struct libwebsocket *wsi, struct libwebsocket_pollfd *pfd)
lws_plat_change_pollfd(struct lws_context *context,
struct lws *wsi, struct lws_pollfd *pfd)
{
return 0;
}

View file

@ -35,8 +35,8 @@ time_t time(time_t *t)
/* file descriptor hash management */
struct libwebsocket *
wsi_from_fd(struct libwebsocket_context *context, int fd)
struct lws *
wsi_from_fd(struct lws_context *context, int fd)
{
int h = LWS_FD_HASH(fd);
int n = 0;
@ -49,7 +49,7 @@ wsi_from_fd(struct libwebsocket_context *context, int fd)
}
int
insert_wsi(struct libwebsocket_context *context, struct libwebsocket *wsi)
insert_wsi(struct lws_context *context, struct lws *wsi)
{
int h = LWS_FD_HASH(wsi->sock);
@ -64,7 +64,7 @@ insert_wsi(struct libwebsocket_context *context, struct libwebsocket *wsi)
}
int
delete_from_fd(struct libwebsocket_context *context, int fd)
delete_from_fd(struct lws_context *context, int fd)
{
int h = LWS_FD_HASH(fd);
int n = 0;
@ -86,7 +86,7 @@ delete_from_fd(struct libwebsocket_context *context, int fd)
return 1;
}
LWS_VISIBLE int lws_get_random(struct libwebsocket_context *context,
LWS_VISIBLE int lws_get_random(struct lws_context *context,
void *buf, int len)
{
int n;
@ -98,12 +98,12 @@ LWS_VISIBLE int lws_get_random(struct libwebsocket_context *context,
return n;
}
LWS_VISIBLE int lws_send_pipe_choked(struct libwebsocket *wsi)
LWS_VISIBLE int lws_send_pipe_choked(struct lws *wsi)
{
return wsi->sock_send_blocking;
}
LWS_VISIBLE int lws_poll_listen_fd(struct libwebsocket_pollfd *fd)
LWS_VISIBLE int lws_poll_listen_fd(struct lws_pollfd *fd)
{
fd_set readfds;
struct timeval tv = { 0, 0 };
@ -124,7 +124,7 @@ LWS_VISIBLE int lws_poll_listen_fd(struct libwebsocket_pollfd *fd)
* immediately return.
*/
LWS_VISIBLE void
lws_cancel_service(struct libwebsocket_context *context)
lws_cancel_service(struct lws_context *context)
{
WSASetEvent(context->events[0]);
}
@ -135,14 +135,14 @@ LWS_VISIBLE void lwsl_emit_syslog(int level, const char *line)
}
LWS_VISIBLE int
lws_plat_service(struct libwebsocket_context *context, int timeout_ms)
lws_plat_service(struct lws_context *context, int timeout_ms)
{
int n;
int i;
DWORD ev;
WSANETWORKEVENTS networkevents;
struct libwebsocket_pollfd *pfd;
struct libwebsocket *wsi;
struct lws_pollfd *pfd;
struct lws *wsi;
/* stay dead once we are dead */
@ -207,7 +207,7 @@ lws_plat_service(struct libwebsocket_context *context, int timeout_ms)
}
LWS_VISIBLE int
lws_plat_set_socket_options(struct libwebsocket_context *context, int fd)
lws_plat_set_socket_options(struct lws_context *context, int fd)
{
int optval = 1;
int optlen = sizeof(optval);
@ -254,12 +254,12 @@ lws_plat_drop_app_privileges(struct lws_context_creation_info *info)
}
LWS_VISIBLE int
lws_plat_init_lookup(struct libwebsocket_context *context)
lws_plat_init_lookup(struct lws_context *context)
{
int i;
for (i = 0; i < FD_HASHTABLE_MODULUS; i++) {
context->fd_hashtable[i].wsi = lws_zalloc(sizeof(struct libwebsocket*) * context->max_fds);
context->fd_hashtable[i].wsi = lws_zalloc(sizeof(struct lws*) * context->max_fds);
if (!context->fd_hashtable[i].wsi) {
return -1;
@ -270,7 +270,7 @@ lws_plat_init_lookup(struct libwebsocket_context *context)
}
LWS_VISIBLE int
lws_plat_init_fd_tables(struct libwebsocket_context *context)
lws_plat_init_fd_tables(struct lws_context *context)
{
context->events = lws_malloc(sizeof(WSAEVENT) * (context->max_fds + 1));
if (context->events == NULL) {
@ -310,7 +310,7 @@ lws_plat_context_early_init(void)
}
LWS_VISIBLE void
lws_plat_context_early_destroy(struct libwebsocket_context *context)
lws_plat_context_early_destroy(struct lws_context *context)
{
if (context->events) {
WSACloseEvent(context->events[0]);
@ -319,7 +319,7 @@ lws_plat_context_early_destroy(struct libwebsocket_context *context)
}
LWS_VISIBLE void
lws_plat_context_late_destroy(struct libwebsocket_context *context)
lws_plat_context_late_destroy(struct lws_context *context)
{
int n;
@ -332,7 +332,7 @@ lws_plat_context_late_destroy(struct libwebsocket_context *context)
}
LWS_VISIBLE int
interface_to_sa(struct libwebsocket_context *context,
interface_to_sa(struct lws_context *context,
const char *ifname, struct sockaddr_in *addr, size_t addrlen)
{
long long address = inet_addr(ifname);
@ -352,8 +352,8 @@ interface_to_sa(struct libwebsocket_context *context,
}
LWS_VISIBLE void
lws_plat_insert_socket_into_fds(struct libwebsocket_context *context,
struct libwebsocket *wsi)
lws_plat_insert_socket_into_fds(struct lws_context *context,
struct lws *wsi)
{
context->fds[context->fds_count++].revents = 0;
context->events[context->fds_count] = WSACreateEvent();
@ -361,21 +361,21 @@ lws_plat_insert_socket_into_fds(struct libwebsocket_context *context,
}
LWS_VISIBLE void
lws_plat_delete_socket_from_fds(struct libwebsocket_context *context,
struct libwebsocket *wsi, int m)
lws_plat_delete_socket_from_fds(struct lws_context *context,
struct lws *wsi, int m)
{
WSACloseEvent(context->events[m + 1]);
context->events[m + 1] = context->events[context->fds_count + 1];
}
LWS_VISIBLE void
lws_plat_service_periodic(struct libwebsocket_context *context)
lws_plat_service_periodic(struct lws_context *context)
{
}
LWS_VISIBLE int
lws_plat_change_pollfd(struct libwebsocket_context *context,
struct libwebsocket *wsi, struct libwebsocket_pollfd *pfd)
lws_plat_change_pollfd(struct lws_context *context,
struct lws *wsi, struct lws_pollfd *pfd)
{
long networkevents = LWS_POLLHUP;

View file

@ -22,7 +22,7 @@
#include "private-libwebsockets.h"
static int
lws_0405_frame_mask_generate(struct libwebsocket *wsi)
lws_0405_frame_mask_generate(struct lws *wsi)
{
int n;
@ -90,9 +90,9 @@ LWS_VISIBLE void lwsl_hexdump(void *vbuf, size_t len)
* notice this returns number of bytes consumed, or -1
*/
int lws_issue_raw(struct libwebsocket *wsi, unsigned char *buf, size_t len)
int lws_issue_raw(struct lws *wsi, unsigned char *buf, size_t len)
{
struct libwebsocket_context *context = wsi->protocol->owning_server;
struct lws_context *context = wsi->protocol->owning_server;
int n;
size_t real_len = len;
int m;
@ -246,7 +246,7 @@ handle_truncated_send:
* pressure at any given time.
*/
LWS_VISIBLE int lws_write(struct libwebsocket *wsi, unsigned char *buf,
LWS_VISIBLE int lws_write(struct lws *wsi, unsigned char *buf,
size_t len, enum lws_write_protocol protocol)
{
int n;
@ -516,7 +516,7 @@ send_raw:
}
LWS_VISIBLE int lws_serve_http_file_fragment(
struct libwebsocket_context *context, struct libwebsocket *wsi)
struct lws_context *context, struct lws *wsi)
{
int n;
int m;
@ -580,8 +580,8 @@ all_sent:
#if LWS_POSIX
LWS_VISIBLE int
lws_ssl_capable_read_no_ssl(struct libwebsocket_context *context,
struct libwebsocket *wsi, unsigned char *buf, int len)
lws_ssl_capable_read_no_ssl(struct lws_context *context,
struct lws *wsi, unsigned char *buf, int len)
{
int n;
@ -601,7 +601,7 @@ lws_ssl_capable_read_no_ssl(struct libwebsocket_context *context,
}
LWS_VISIBLE int
lws_ssl_capable_write_no_ssl(struct libwebsocket *wsi, unsigned char *buf, int len)
lws_ssl_capable_write_no_ssl(struct lws *wsi, unsigned char *buf, int len)
{
int n = 0;
@ -631,7 +631,7 @@ lws_ssl_capable_write_no_ssl(struct libwebsocket *wsi, unsigned char *buf, int l
}
#endif
LWS_VISIBLE int
lws_ssl_pending_no_ssl(struct libwebsocket *wsi)
lws_ssl_pending_no_ssl(struct lws *wsi)
{
(void)wsi;
return 0;

View file

@ -59,7 +59,7 @@ int lextable_decode(int pos, char c)
}
}
int lws_allocate_header_table(struct libwebsocket *wsi)
int lws_allocate_header_table(struct lws *wsi)
{
/* Be sure to free any existing header data to avoid mem leak: */
lws_free_header_table(wsi);
@ -75,14 +75,14 @@ int lws_allocate_header_table(struct libwebsocket *wsi)
return 0;
}
int lws_free_header_table(struct libwebsocket *wsi)
int lws_free_header_table(struct lws *wsi)
{
lws_free2(wsi->u.hdr.ah);
wsi->u.hdr.ah = NULL;
return 0;
};
LWS_VISIBLE int lws_hdr_total_length(struct libwebsocket *wsi, enum lws_token_indexes h)
LWS_VISIBLE int lws_hdr_total_length(struct lws *wsi, enum lws_token_indexes h)
{
int n;
int len = 0;
@ -98,7 +98,7 @@ LWS_VISIBLE int lws_hdr_total_length(struct libwebsocket *wsi, enum lws_token_in
return len;
}
LWS_VISIBLE int lws_hdr_copy(struct libwebsocket *wsi, char *dest, int len,
LWS_VISIBLE int lws_hdr_copy(struct lws *wsi, char *dest, int len,
enum lws_token_indexes h)
{
int toklen = lws_hdr_total_length(wsi, h);
@ -121,7 +121,7 @@ LWS_VISIBLE int lws_hdr_copy(struct libwebsocket *wsi, char *dest, int len,
return toklen;
}
char *lws_hdr_simple_ptr(struct libwebsocket *wsi, enum lws_token_indexes h)
char *lws_hdr_simple_ptr(struct lws *wsi, enum lws_token_indexes h)
{
int n;
@ -132,7 +132,7 @@ char *lws_hdr_simple_ptr(struct libwebsocket *wsi, enum lws_token_indexes h)
return &wsi->u.hdr.ah->data[wsi->u.hdr.ah->frags[n].offset];
}
int lws_hdr_simple_create(struct libwebsocket *wsi,
int lws_hdr_simple_create(struct lws *wsi,
enum lws_token_indexes h, const char *s)
{
wsi->u.hdr.ah->next_frag_index++;
@ -178,7 +178,7 @@ static signed char char_to_hex(const char c)
return -1;
}
static int issue_char(struct libwebsocket *wsi, unsigned char c)
static int issue_char(struct lws *wsi, unsigned char c)
{
unsigned short frag_len;
if (wsi->u.hdr.ah->pos == sizeof(wsi->u.hdr.ah->data)) {
@ -207,8 +207,8 @@ static int issue_char(struct libwebsocket *wsi, unsigned char c)
}
int lws_parse(
struct libwebsocket_context *context,
struct libwebsocket *wsi, unsigned char c)
struct lws_context *context,
struct lws *wsi, unsigned char c)
{
static const unsigned char methods[] = {
WSI_TOKEN_GET_URI,
@ -572,13 +572,13 @@ set_parsing_complete:
* mode.
*/
LWS_VISIBLE int lws_frame_is_binary(struct libwebsocket *wsi)
LWS_VISIBLE int lws_frame_is_binary(struct lws *wsi)
{
return wsi->u.ws.frame_is_binary;
}
int
lws_rx_sm(struct libwebsocket *wsi, unsigned char c)
lws_rx_sm(struct lws *wsi, unsigned char c)
{
struct lws_tokens eff_buf;
int ret = 0;
@ -998,7 +998,7 @@ ping_drop:
wsi->protocol->callback,
wsi->protocol->owning_server,
wsi,
(enum libwebsocket_callback_reasons)callback_action,
(enum lws_callback_reasons)callback_action,
wsi->user_space,
eff_buf.token,
eff_buf.token_len);
@ -1039,7 +1039,7 @@ illegal_ctl_length:
*/
LWS_VISIBLE size_t
lws_remaining_packet_payload(struct libwebsocket *wsi)
lws_remaining_packet_payload(struct lws *wsi)
{
return wsi->u.ws.rx_packet_length;
}

View file

@ -22,10 +22,10 @@
#include "private-libwebsockets.h"
int
insert_wsi_socket_into_fds(struct libwebsocket_context *context,
struct libwebsocket *wsi)
insert_wsi_socket_into_fds(struct lws_context *context,
struct lws *wsi)
{
struct libwebsocket_pollargs pa = { wsi->sock, LWS_POLLIN, 0 };
struct lws_pollargs pa = { wsi->sock, LWS_POLLIN, 0 };
if (context->fds_count >= context->max_fds) {
lwsl_err("Too many fds (%d)\n", context->max_fds);
@ -70,11 +70,11 @@ insert_wsi_socket_into_fds(struct libwebsocket_context *context,
}
int
remove_wsi_socket_from_fds(struct libwebsocket_context *context,
struct libwebsocket *wsi)
remove_wsi_socket_from_fds(struct lws_context *context,
struct lws *wsi)
{
int m;
struct libwebsocket_pollargs pa = { wsi->sock, 0, 0 };
struct lws_pollargs pa = { wsi->sock, 0, 0 };
lws_libev_io(context, wsi, LWS_EV_STOP | LWS_EV_READ | LWS_EV_WRITE);
@ -130,13 +130,13 @@ remove_wsi_socket_from_fds(struct libwebsocket_context *context,
}
int
lws_change_pollfd(struct libwebsocket *wsi, int _and, int _or)
lws_change_pollfd(struct lws *wsi, int _and, int _or)
{
struct libwebsocket_context *context;
struct lws_context *context;
int tid;
int sampled_tid;
struct libwebsocket_pollfd *pfd;
struct libwebsocket_pollargs pa;
struct lws_pollfd *pfd;
struct lws_pollargs pa;
if (!wsi || !wsi->protocol || wsi->position_in_fds_table < 0)
return 1;
@ -206,11 +206,11 @@ lws_change_pollfd(struct libwebsocket *wsi, int _and, int _or)
*/
LWS_VISIBLE int
lws_callback_on_writable(struct libwebsocket_context *context,
struct libwebsocket *wsi)
lws_callback_on_writable(struct lws_context *context,
struct lws *wsi)
{
#ifdef LWS_USE_HTTP2
struct libwebsocket *network_wsi, *wsi2;
struct lws *network_wsi, *wsi2;
int already;
lwsl_info("%s: %p\n", __func__, wsi);
@ -285,11 +285,11 @@ network_sock:
LWS_VISIBLE int
lws_callback_on_writable_all_protocol(
const struct libwebsocket_protocols *protocol)
const struct lws_protocols *protocol)
{
struct libwebsocket_context *context = protocol->owning_server;
struct lws_context *context = protocol->owning_server;
int n;
struct libwebsocket *wsi;
struct lws *wsi;
for (n = 0; n < context->fds_count; n++) {
wsi = wsi_from_fd(context,context->fds[n].fd);

View file

@ -442,39 +442,39 @@ enum {
LWS_RXFLOW_PENDING_CHANGE = (1 << 1),
};
struct libwebsocket_protocols;
struct libwebsocket;
struct lws_protocols;
struct lws;
#ifdef LWS_USE_LIBEV
struct lws_io_watcher {
struct ev_io watcher;
struct libwebsocket_context* context;
struct lws_context* context;
};
struct lws_signal_watcher {
struct ev_signal watcher;
struct libwebsocket_context* context;
struct lws_context* context;
};
#endif /* LWS_USE_LIBEV */
#ifdef _WIN32
#define LWS_FD_HASH(fd) ((fd ^ (fd >> 8) ^ (fd >> 16)) % FD_HASHTABLE_MODULUS)
struct lws_fd_hashtable {
struct libwebsocket **wsi;
struct lws **wsi;
int length;
};
#endif
struct libwebsocket_context {
struct lws_context {
#ifdef _WIN32
WSAEVENT *events;
#endif
struct libwebsocket_pollfd *fds;
struct lws_pollfd *fds;
#ifdef _WIN32
/* different implementation between unix and windows */
struct lws_fd_hashtable fd_hashtable[FD_HASHTABLE_MODULUS];
#else
struct libwebsocket **lws_lookup; /* fd to wsi */
struct lws **lws_lookup; /* fd to wsi */
#endif
int fds_count;
#ifdef LWS_USE_LIBEV
@ -535,15 +535,15 @@ struct libwebsocket_context {
unsigned int user_supplied_ssl_ctx:1;
SSL_CTX *ssl_ctx;
SSL_CTX *ssl_client_ctx;
struct libwebsocket *pending_read_list; /* linked list */
struct lws *pending_read_list; /* linked list */
#define lws_ssl_anybody_has_buffered_read(ctx) (ctx->use_ssl && ctx->pending_read_list)
#else
#define lws_ssl_anybody_has_buffered_read(ctx) (0)
#endif
struct libwebsocket_protocols *protocols;
struct lws_protocols *protocols;
int count_protocols;
#ifndef LWS_NO_EXTENSIONS
struct libwebsocket_extension *extensions;
struct lws_extension *extensions;
#endif
struct lws_token_limits *token_limits;
void *user_space;
@ -560,15 +560,15 @@ enum {
#define LWS_LIBEV_ENABLED(context) (context->options & LWS_SERVER_OPTION_LIBEV)
LWS_EXTERN void lws_feature_status_libev(struct lws_context_creation_info *info);
LWS_EXTERN void
lws_libev_accept(struct libwebsocket_context *context,
struct libwebsocket *new_wsi, lws_sockfd_type accept_fd);
lws_libev_accept(struct lws_context *context,
struct lws *new_wsi, lws_sockfd_type accept_fd);
LWS_EXTERN void
lws_libev_io(struct libwebsocket_context *context,
struct libwebsocket *wsi, int flags);
lws_libev_io(struct lws_context *context,
struct lws *wsi, int flags);
LWS_EXTERN int
lws_libev_init_fd_table(struct libwebsocket_context *context);
lws_libev_init_fd_table(struct lws_context *context);
LWS_EXTERN void
lws_libev_run(struct libwebsocket_context *context);
lws_libev_run(struct lws_context *context);
#else
#define LWS_LIBEV_ENABLED(context) (0)
#ifdef LWS_POSIX
@ -758,8 +758,8 @@ struct _lws_http2_related {
struct http2_settings my_settings;
struct http2_settings peer_settings;
struct libwebsocket *parent_wsi;
struct libwebsocket *next_child_wsi;
struct lws *parent_wsi;
struct lws *next_child_wsi;
struct hpack_dynamic_table *hpack_dyn_table;
@ -768,7 +768,7 @@ struct _lws_http2_related {
/* frame */
unsigned int length;
unsigned int stream_id;
struct libwebsocket *stream_wsi;
struct lws *stream_wsi;
unsigned char type;
unsigned char flags;
unsigned char frame_state;
@ -845,7 +845,7 @@ struct _lws_websocket_related {
unsigned char ping_pending_flag;
};
struct libwebsocket {
struct lws {
/* lifetime members */
@ -853,9 +853,9 @@ struct libwebsocket {
struct lws_io_watcher w_read;
struct lws_io_watcher w_write;
#endif /* LWS_USE_LIBEV */
const struct libwebsocket_protocols *protocol;
const struct lws_protocols *protocol;
#ifndef LWS_NO_EXTENSIONS
struct libwebsocket_extension *
struct lws_extension *
active_extensions[LWS_MAX_EXTENSIONS_ACTIVE];
void *active_extensions_user[LWS_MAX_EXTENSIONS_ACTIVE];
unsigned char count_active_extensions;
@ -909,7 +909,7 @@ struct libwebsocket {
#ifdef LWS_OPENSSL_SUPPORT
SSL *ssl;
BIO *client_bio;
struct libwebsocket *pending_read_list_prev, *pending_read_list_next;
struct lws *pending_read_list_prev, *pending_read_list_next;
unsigned int use_ssl:2;
unsigned int upgraded:1;
#endif
@ -922,54 +922,54 @@ struct libwebsocket {
LWS_EXTERN int log_level;
LWS_EXTERN void
lws_close_and_free_session(struct libwebsocket_context *context,
struct libwebsocket *wsi, enum lws_close_status);
lws_close_and_free_session(struct lws_context *context,
struct lws *wsi, enum lws_close_status);
LWS_EXTERN int
remove_wsi_socket_from_fds(struct libwebsocket_context *context,
struct libwebsocket *wsi);
remove_wsi_socket_from_fds(struct lws_context *context,
struct lws *wsi);
LWS_EXTERN int
lws_rxflow_cache(struct libwebsocket *wsi, unsigned char *buf, int n, int len);
lws_rxflow_cache(struct lws *wsi, unsigned char *buf, int n, int len);
#ifndef LWS_LATENCY
static inline void lws_latency(struct libwebsocket_context *context,
struct libwebsocket *wsi, const char *action,
static inline void lws_latency(struct lws_context *context,
struct lws *wsi, const char *action,
int ret, int completion) { do { (void)context; (void)wsi; (void)action; (void)ret; (void)completion; } while (0); }
static inline void lws_latency_pre(struct libwebsocket_context *context,
struct libwebsocket *wsi) { do { (void)context; (void)wsi; } while (0); }
static inline void lws_latency_pre(struct lws_context *context,
struct lws *wsi) { do { (void)context; (void)wsi; } while (0); }
#else
#define lws_latency_pre(_context, _wsi) lws_latency(_context, _wsi, NULL, 0, 0)
extern void
lws_latency(struct libwebsocket_context *context,
struct libwebsocket *wsi, const char *action,
lws_latency(struct lws_context *context,
struct lws *wsi, const char *action,
int ret, int completion);
#endif
LWS_EXTERN void lws_set_protocol_write_pending(struct libwebsocket_context *context,
struct libwebsocket *wsi,
LWS_EXTERN void lws_set_protocol_write_pending(struct lws_context *context,
struct lws *wsi,
enum lws_pending_protocol_send pend);
LWS_EXTERN int
lws_client_rx_sm(struct libwebsocket *wsi, unsigned char c);
lws_client_rx_sm(struct lws *wsi, unsigned char c);
LWS_EXTERN int
lws_parse(struct libwebsocket_context *context,
struct libwebsocket *wsi, unsigned char c);
lws_parse(struct lws_context *context,
struct lws *wsi, unsigned char c);
LWS_EXTERN int
lws_http_action(struct libwebsocket_context *context, struct libwebsocket *wsi);
lws_http_action(struct lws_context *context, struct lws *wsi);
LWS_EXTERN int
lws_b64_selftest(void);
#if defined(_WIN32) || defined(MBED_OPERATORS)
LWS_EXTERN struct libwebsocket *
wsi_from_fd(struct libwebsocket_context *context, lws_sockfd_type fd);
LWS_EXTERN struct lws *
wsi_from_fd(struct lws_context *context, lws_sockfd_type fd);
LWS_EXTERN int
insert_wsi(struct libwebsocket_context *context, struct libwebsocket *wsi);
insert_wsi(struct lws_context *context, struct lws *wsi);
LWS_EXTERN int
delete_from_fd(struct libwebsocket_context *context, lws_sockfd_type fd);
delete_from_fd(struct lws_context *context, lws_sockfd_type fd);
#else
#define wsi_from_fd(A,B) A->lws_lookup[B]
#define insert_wsi(A,B) A->lws_lookup[B->sock]=B
@ -977,31 +977,31 @@ delete_from_fd(struct libwebsocket_context *context, lws_sockfd_type fd);
#endif
LWS_EXTERN int
insert_wsi_socket_into_fds(struct libwebsocket_context *context,
struct libwebsocket *wsi);
insert_wsi_socket_into_fds(struct lws_context *context,
struct lws *wsi);
LWS_EXTERN int
lws_issue_raw(struct libwebsocket *wsi, unsigned char *buf, size_t len);
lws_issue_raw(struct lws *wsi, unsigned char *buf, size_t len);
LWS_EXTERN int
lws_service_timeout_check(struct libwebsocket_context *context,
struct libwebsocket *wsi, unsigned int sec);
lws_service_timeout_check(struct lws_context *context,
struct lws *wsi, unsigned int sec);
LWS_EXTERN struct libwebsocket *
lws_client_connect_2(struct libwebsocket_context *context,
struct libwebsocket *wsi);
LWS_EXTERN struct lws *
lws_client_connect_2(struct lws_context *context,
struct lws *wsi);
LWS_EXTERN struct libwebsocket *
lws_create_new_server_wsi(struct libwebsocket_context *context);
LWS_EXTERN struct lws *
lws_create_new_server_wsi(struct lws_context *context);
LWS_EXTERN char *
lws_generate_client_handshake(struct libwebsocket_context *context,
struct libwebsocket *wsi, char *pkt);
lws_generate_client_handshake(struct lws_context *context,
struct lws *wsi, char *pkt);
LWS_EXTERN int
lws_handle_POLLOUT_event(struct libwebsocket_context *context,
struct libwebsocket *wsi, struct libwebsocket_pollfd *pollfd);
lws_handle_POLLOUT_event(struct lws_context *context,
struct lws *wsi, struct lws_pollfd *pollfd);
/*
* EXTENSIONS
@ -1010,19 +1010,19 @@ lws_handle_POLLOUT_event(struct libwebsocket_context *context,
#ifndef LWS_NO_EXTENSIONS
LWS_VISIBLE void
lws_context_init_extensions(struct lws_context_creation_info *info,
struct libwebsocket_context *context);
struct lws_context *context);
LWS_EXTERN int
lws_any_extension_handled(struct libwebsocket_context *context,
struct libwebsocket *wsi,
enum libwebsocket_extension_callback_reasons r,
lws_any_extension_handled(struct lws_context *context,
struct lws *wsi,
enum lws_extension_callback_reasons r,
void *v, size_t len);
LWS_EXTERN int
lws_ext_callback_for_each_active(struct libwebsocket *wsi, int reason,
lws_ext_callback_for_each_active(struct lws *wsi, int reason,
void *buf, int len);
LWS_EXTERN int
lws_ext_callback_for_each_extension_type(
struct libwebsocket_context *context, struct libwebsocket *wsi,
struct lws_context *context, struct lws *wsi,
int reason, void *arg, int len);
#else
#define lws_any_extension_handled(_a, _b, _c, _d, _e) (0)
@ -1033,104 +1033,104 @@ lws_ext_callback_for_each_extension_type(
#endif
LWS_EXTERN int
lws_client_interpret_server_handshake(struct libwebsocket_context *context,
struct libwebsocket *wsi);
lws_client_interpret_server_handshake(struct lws_context *context,
struct lws *wsi);
LWS_EXTERN int
lws_rx_sm(struct libwebsocket *wsi, unsigned char c);
lws_rx_sm(struct lws *wsi, unsigned char c);
LWS_EXTERN int
lws_issue_raw_ext_access(struct libwebsocket *wsi,
lws_issue_raw_ext_access(struct lws *wsi,
unsigned char *buf, size_t len);
LWS_EXTERN int
_lws_rx_flow_control(struct libwebsocket *wsi);
_lws_rx_flow_control(struct lws *wsi);
LWS_EXTERN void
lws_union_transition(struct libwebsocket *wsi, enum connection_mode mode);
lws_union_transition(struct lws *wsi, enum connection_mode mode);
LWS_EXTERN int
user_callback_handle_rxflow(callback_function,
struct libwebsocket_context *context,
struct libwebsocket *wsi,
enum libwebsocket_callback_reasons reason, void *user,
struct lws_context *context,
struct lws *wsi,
enum lws_callback_reasons reason, void *user,
void *in, size_t len);
#ifdef LWS_USE_HTTP2
LWS_EXTERN struct libwebsocket *lws_http2_get_network_wsi(struct libwebsocket *wsi);
struct libwebsocket * lws_http2_get_nth_child(struct libwebsocket *wsi, int n);
LWS_EXTERN struct lws *lws_http2_get_network_wsi(struct lws *wsi);
struct lws * lws_http2_get_nth_child(struct lws *wsi, int n);
LWS_EXTERN int
lws_http2_interpret_settings_payload(struct http2_settings *settings, unsigned char *buf, int len);
LWS_EXTERN void lws_http2_init(struct http2_settings *settings);
LWS_EXTERN int
lws_http2_parser(struct libwebsocket_context *context,
struct libwebsocket *wsi, unsigned char c);
LWS_EXTERN int lws_http2_do_pps_send(struct libwebsocket_context *context, struct libwebsocket *wsi);
LWS_EXTERN int lws_http2_frame_write(struct libwebsocket *wsi, int type, int flags, unsigned int sid, unsigned int len, unsigned char *buf);
LWS_EXTERN struct libwebsocket *
lws_http2_wsi_from_id(struct libwebsocket *wsi, unsigned int sid);
LWS_EXTERN int lws_hpack_interpret(struct libwebsocket_context *context,
struct libwebsocket *wsi,
lws_http2_parser(struct lws_context *context,
struct lws *wsi, unsigned char c);
LWS_EXTERN int lws_http2_do_pps_send(struct lws_context *context, struct lws *wsi);
LWS_EXTERN int lws_http2_frame_write(struct lws *wsi, int type, int flags, unsigned int sid, unsigned int len, unsigned char *buf);
LWS_EXTERN struct lws *
lws_http2_wsi_from_id(struct lws *wsi, unsigned int sid);
LWS_EXTERN int lws_hpack_interpret(struct lws_context *context,
struct lws *wsi,
unsigned char c);
LWS_EXTERN int
lws_add_http2_header_by_name(struct libwebsocket_context *context,
struct libwebsocket *wsi,
lws_add_http2_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_EXTERN int
lws_add_http2_header_by_token(struct libwebsocket_context *context,
struct libwebsocket *wsi,
lws_add_http2_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_EXTERN int
lws_add_http2_header_status(struct libwebsocket_context *context,
struct libwebsocket *wsi,
lws_add_http2_header_status(struct lws_context *context,
struct lws *wsi,
unsigned int code,
unsigned char **p,
unsigned char *end);
LWS_EXTERN
void lws_http2_configure_if_upgraded(struct libwebsocket *wsi);
void lws_http2_configure_if_upgraded(struct lws *wsi);
#else
#define lws_http2_configure_if_upgraded(x)
#endif
LWS_EXTERN int
lws_plat_set_socket_options(struct libwebsocket_context *context, lws_sockfd_type fd);
lws_plat_set_socket_options(struct lws_context *context, lws_sockfd_type fd);
LWS_EXTERN int
lws_allocate_header_table(struct libwebsocket *wsi);
lws_allocate_header_table(struct lws *wsi);
LWS_EXTERN int
lws_free_header_table(struct libwebsocket *wsi);
lws_free_header_table(struct lws *wsi);
LWS_EXTERN char *
lws_hdr_simple_ptr(struct libwebsocket *wsi, enum lws_token_indexes h);
lws_hdr_simple_ptr(struct lws *wsi, enum lws_token_indexes h);
LWS_EXTERN int
lws_hdr_simple_create(struct libwebsocket *wsi,
lws_hdr_simple_create(struct lws *wsi,
enum lws_token_indexes h, const char *s);
LWS_EXTERN int
lws_ensure_user_space(struct libwebsocket *wsi);
lws_ensure_user_space(struct lws *wsi);
LWS_EXTERN int
lws_change_pollfd(struct libwebsocket *wsi, int _and, int _or);
lws_change_pollfd(struct lws *wsi, int _and, int _or);
#ifndef LWS_NO_SERVER
int lws_context_init_server(struct lws_context_creation_info *info,
struct libwebsocket_context *context);
LWS_EXTERN int handshake_0405(struct libwebsocket_context *context,
struct libwebsocket *wsi);
struct lws_context *context);
LWS_EXTERN int handshake_0405(struct lws_context *context,
struct lws *wsi);
LWS_EXTERN int
lws_interpret_incoming_packet(struct libwebsocket *wsi,
lws_interpret_incoming_packet(struct lws *wsi,
unsigned char *buf, size_t len);
LWS_EXTERN void
lws_server_get_canonical_hostname(struct libwebsocket_context *context,
lws_server_get_canonical_hostname(struct lws_context *context,
struct lws_context_creation_info *info);
#else
#define lws_context_init_server(_a, _b) (0)
@ -1145,7 +1145,7 @@ LWS_EXTERN int get_daemonize_pid();
#endif
#if !defined(MBED_OPERATORS)
LWS_EXTERN int interface_to_sa(struct libwebsocket_context *context,
LWS_EXTERN int interface_to_sa(struct lws_context *context,
const char *ifname, struct sockaddr_in *addr, size_t addrlen);
#endif
LWS_EXTERN void lwsl_emit_stderr(int level, const char *line);
@ -1177,64 +1177,64 @@ enum lws_ssl_capable_status {
#define LWS_SSL_ENABLED(context) (context->use_ssl)
LWS_EXTERN int openssl_websocket_private_data_index;
LWS_EXTERN int
lws_ssl_capable_read(struct libwebsocket_context *context,
struct libwebsocket *wsi, unsigned char *buf, int len);
lws_ssl_capable_read(struct lws_context *context,
struct lws *wsi, unsigned char *buf, int len);
LWS_EXTERN int
lws_ssl_capable_write(struct libwebsocket *wsi, unsigned char *buf, int len);
lws_ssl_capable_write(struct lws *wsi, unsigned char *buf, int len);
LWS_EXTERN int
lws_ssl_pending(struct libwebsocket *wsi);
lws_ssl_pending(struct lws *wsi);
LWS_EXTERN int
lws_server_socket_service_ssl(struct libwebsocket_context *context,
struct libwebsocket **wsi, struct libwebsocket *new_wsi,
lws_sockfd_type accept_fd, struct libwebsocket_pollfd *pollfd);
lws_server_socket_service_ssl(struct lws_context *context,
struct lws **wsi, struct lws *new_wsi,
lws_sockfd_type accept_fd, struct lws_pollfd *pollfd);
LWS_EXTERN int
lws_ssl_close(struct libwebsocket *wsi);
lws_ssl_close(struct lws *wsi);
LWS_EXTERN void
lws_ssl_context_destroy(struct libwebsocket_context *context);
lws_ssl_context_destroy(struct lws_context *context);
LWS_VISIBLE void
lws_ssl_remove_wsi_from_buffered_list(struct libwebsocket_context *context,
struct libwebsocket *wsi);
lws_ssl_remove_wsi_from_buffered_list(struct lws_context *context,
struct lws *wsi);
#ifndef LWS_NO_SERVER
LWS_EXTERN int
lws_context_init_server_ssl(struct lws_context_creation_info *info,
struct libwebsocket_context *context);
struct lws_context *context);
#else
#define lws_context_init_server_ssl(_a, _b) (0)
#endif
LWS_EXTERN void
lws_ssl_destroy(struct libwebsocket_context *context);
lws_ssl_destroy(struct lws_context *context);
/* HTTP2-related */
#ifdef LWS_USE_HTTP2
LWS_EXTERN void
lws_context_init_http2_ssl(struct libwebsocket_context *context);
lws_context_init_http2_ssl(struct lws_context *context);
#else
#define lws_context_init_http2_ssl(_a)
#endif
#endif
LWS_EXTERN int
lws_ssl_capable_read_no_ssl(struct libwebsocket_context *context,
struct libwebsocket *wsi, unsigned char *buf, int len);
lws_ssl_capable_read_no_ssl(struct lws_context *context,
struct lws *wsi, unsigned char *buf, int len);
LWS_EXTERN int
lws_ssl_capable_write_no_ssl(struct libwebsocket *wsi, unsigned char *buf, int len);
lws_ssl_capable_write_no_ssl(struct lws *wsi, unsigned char *buf, int len);
LWS_EXTERN int
lws_ssl_pending_no_ssl(struct libwebsocket *wsi);
lws_ssl_pending_no_ssl(struct lws *wsi);
#ifndef LWS_NO_CLIENT
LWS_EXTERN int lws_client_socket_service(
struct libwebsocket_context *context,
struct libwebsocket *wsi, struct libwebsocket_pollfd *pollfd);
struct lws_context *context,
struct lws *wsi, struct lws_pollfd *pollfd);
#ifdef LWS_OPENSSL_SUPPORT
LWS_EXTERN int lws_context_init_client_ssl(struct lws_context_creation_info *info,
struct libwebsocket_context *context);
struct lws_context *context);
#else
#define lws_context_init_client_ssl(_a, _b) (0)
#endif
LWS_EXTERN int lws_handshake_client(struct libwebsocket *wsi, unsigned char **buf, size_t len);
LWS_EXTERN int lws_handshake_client(struct lws *wsi, unsigned char **buf, size_t len);
LWS_EXTERN void
lws_decode_ssl_error(void);
#else
@ -1243,18 +1243,18 @@ lws_ssl_pending_no_ssl(struct libwebsocket *wsi);
#endif
#ifndef LWS_NO_SERVER
LWS_EXTERN int lws_server_socket_service(
struct libwebsocket_context *context,
struct libwebsocket *wsi, struct libwebsocket_pollfd *pollfd);
LWS_EXTERN int _lws_rx_flow_control(struct libwebsocket *wsi);
LWS_EXTERN int lws_handshake_server(struct libwebsocket_context *context,
struct libwebsocket *wsi, unsigned char **buf, size_t len);
struct lws_context *context,
struct lws *wsi, struct lws_pollfd *pollfd);
LWS_EXTERN int _lws_rx_flow_control(struct lws *wsi);
LWS_EXTERN int lws_handshake_server(struct lws_context *context,
struct lws *wsi, unsigned char **buf, size_t len);
#else
#define lws_server_socket_service(_a, _b, _c) (0)
#define _lws_rx_flow_control(_a) (0)
#define lws_handshake_server(_a, _b, _c, _d) (0)
#endif
LWS_EXTERN int lws_get_addresses(struct libwebsocket_context *context,
LWS_EXTERN int lws_get_addresses(struct lws_context *context,
void *ads, char *name, int name_len,
char *rip, int rip_len);
@ -1275,31 +1275,31 @@ lws_zalloc(size_t size);
* lws_plat_
*/
LWS_EXTERN void
lws_plat_delete_socket_from_fds(struct libwebsocket_context *context,
struct libwebsocket *wsi, int m);
lws_plat_delete_socket_from_fds(struct lws_context *context,
struct lws *wsi, int m);
LWS_EXTERN void
lws_plat_insert_socket_into_fds(struct libwebsocket_context *context,
struct libwebsocket *wsi);
lws_plat_insert_socket_into_fds(struct lws_context *context,
struct lws *wsi);
LWS_EXTERN void
lws_plat_service_periodic(struct libwebsocket_context *context);
lws_plat_service_periodic(struct lws_context *context);
LWS_EXTERN int
lws_plat_change_pollfd(struct libwebsocket_context *context,
struct libwebsocket *wsi, struct libwebsocket_pollfd *pfd);
lws_plat_change_pollfd(struct lws_context *context,
struct lws *wsi, struct lws_pollfd *pfd);
LWS_EXTERN int
lws_plat_context_early_init(void);
LWS_EXTERN void
lws_plat_context_early_destroy(struct libwebsocket_context *context);
lws_plat_context_early_destroy(struct lws_context *context);
LWS_EXTERN void
lws_plat_context_late_destroy(struct libwebsocket_context *context);
lws_plat_context_late_destroy(struct lws_context *context);
LWS_EXTERN int
lws_poll_listen_fd(struct libwebsocket_pollfd *fd);
lws_poll_listen_fd(struct lws_pollfd *fd);
LWS_EXTERN int
lws_plat_service(struct libwebsocket_context *context, int timeout_ms);
lws_plat_service(struct lws_context *context, int timeout_ms);
LWS_EXTERN int
lws_plat_init_lookup(struct libwebsocket_context *context);
lws_plat_init_lookup(struct lws_context *context);
LWS_EXTERN int
lws_plat_init_fd_tables(struct libwebsocket_context *context);
lws_plat_init_fd_tables(struct lws_context *context);
LWS_EXTERN void
lws_plat_drop_app_privileges(struct lws_context_creation_info *info);
LWS_EXTERN unsigned long long

View file

@ -24,13 +24,13 @@
#define LWS_CPYAPP(ptr, str) { strcpy(ptr, str); ptr += strlen(str); }
#ifndef LWS_NO_EXTENSIONS
LWS_VISIBLE int
lws_extension_server_handshake(struct libwebsocket_context *context,
struct libwebsocket *wsi, char **p)
lws_extension_server_handshake(struct lws_context *context,
struct lws *wsi, char **p)
{
int n;
char *c;
char ext_name[128];
struct libwebsocket_extension *ext;
struct lws_extension *ext;
int ext_count = 0;
int more = 1;
@ -156,7 +156,7 @@ lws_extension_server_handshake(struct libwebsocket_context *context,
}
#endif
int
handshake_0405(struct libwebsocket_context *context, struct libwebsocket *wsi)
handshake_0405(struct lws_context *context, struct lws *wsi)
{
unsigned char hash[20];
int n;

View file

@ -23,7 +23,7 @@
#include "private-libwebsockets.h"
int lws_context_init_server(struct lws_context_creation_info *info,
struct libwebsocket_context *context)
struct lws_context *context)
{
lws_sockfd_type sockfd;
#if LWS_POSIX
@ -37,7 +37,7 @@ int lws_context_init_server(struct lws_context_creation_info *info,
struct sockaddr *v;
int opt = 1;
#endif
struct libwebsocket *wsi;
struct lws *wsi;
/* set up our external listening socket we serve on */
@ -121,7 +121,7 @@ int lws_context_init_server(struct lws_context_creation_info *info,
context->listen_port = info->port;
wsi = lws_zalloc(sizeof(struct libwebsocket));
wsi = lws_zalloc(sizeof(struct lws));
if (wsi == NULL) {
lwsl_err("Out of mem\n");
compatible_close(sockfd);
@ -151,9 +151,9 @@ int lws_context_init_server(struct lws_context_creation_info *info,
}
int
_lws_rx_flow_control(struct libwebsocket *wsi)
_lws_rx_flow_control(struct lws *wsi)
{
struct libwebsocket_context *context = wsi->protocol->owning_server;
struct lws_context *context = wsi->protocol->owning_server;
/* there is no pending change */
if (!(wsi->rxflow_change_to & LWS_RXFLOW_PENDING_CHANGE))
@ -187,8 +187,8 @@ _lws_rx_flow_control(struct libwebsocket *wsi)
return 0;
}
int lws_http_action(struct libwebsocket_context *context,
struct libwebsocket *wsi)
int lws_http_action(struct lws_context *context,
struct lws *wsi)
{
char *uri_ptr = NULL;
int uri_len = 0;
@ -343,8 +343,8 @@ bail_nuke_ah:
}
int lws_handshake_server(struct libwebsocket_context *context,
struct libwebsocket *wsi, unsigned char **buf, size_t len)
int lws_handshake_server(struct lws_context *context,
struct lws *wsi, unsigned char **buf, size_t len)
{
struct allocated_headers *ah;
int protocol_len;
@ -596,12 +596,12 @@ bail_nuke_ah:
return 1;
}
struct libwebsocket *
lws_create_new_server_wsi(struct libwebsocket_context *context)
struct lws *
lws_create_new_server_wsi(struct lws_context *context)
{
struct libwebsocket *new_wsi;
struct lws *new_wsi;
new_wsi = lws_zalloc(sizeof(struct libwebsocket));
new_wsi = lws_zalloc(sizeof(struct lws));
if (new_wsi == NULL) {
lwsl_err("Out of memory for new connection\n");
return NULL;
@ -656,7 +656,7 @@ lws_create_new_server_wsi(struct libwebsocket_context *context)
*/
LWS_VISIBLE
int lws_http_transaction_completed(struct libwebsocket *wsi)
int lws_http_transaction_completed(struct lws *wsi)
{
/* if we can't go back to accept new headers, drop the connection */
if (wsi->u.http.connection_type != HTTP_CONNECTION_KEEP_ALIVE) {
@ -684,10 +684,10 @@ int lws_http_transaction_completed(struct libwebsocket *wsi)
}
LWS_VISIBLE
int lws_server_socket_service(struct libwebsocket_context *context,
struct libwebsocket *wsi, struct libwebsocket_pollfd *pollfd)
int lws_server_socket_service(struct lws_context *context,
struct lws *wsi, struct lws_pollfd *pollfd)
{
struct libwebsocket *new_wsi = NULL;
struct lws *new_wsi = NULL;
lws_sockfd_type accept_fd = LWS_SOCK_INVALID;
#if LWS_POSIX
socklen_t clilen;
@ -910,8 +910,8 @@ fail:
*/
LWS_VISIBLE int lws_serve_http_file(
struct libwebsocket_context *context,
struct libwebsocket *wsi, const char *file,
struct lws_context *context,
struct lws *wsi, const char *file,
const char *content_type, const char *other_headers,
int other_headers_len)
{
@ -963,7 +963,7 @@ LWS_VISIBLE int lws_serve_http_file(
}
int lws_interpret_incoming_packet(struct libwebsocket *wsi,
int lws_interpret_incoming_packet(struct lws *wsi,
unsigned char *buf, size_t len)
{
size_t n = 0;
@ -1000,7 +1000,7 @@ int lws_interpret_incoming_packet(struct libwebsocket *wsi,
}
LWS_VISIBLE void
lws_server_get_canonical_hostname(struct libwebsocket_context *context,
lws_server_get_canonical_hostname(struct lws_context *context,
struct lws_context_creation_info *info)
{
if (info->options & LWS_SERVER_OPTION_SKIP_SERVER_CANONICAL_NAME)

View file

@ -22,8 +22,8 @@
#include "private-libwebsockets.h"
static int
lws_calllback_as_writeable(struct libwebsocket_context *context,
struct libwebsocket *wsi)
lws_calllback_as_writeable(struct lws_context *context,
struct lws *wsi)
{
int n;
@ -40,18 +40,18 @@ lws_calllback_as_writeable(struct libwebsocket_context *context,
}
lwsl_info("%s: %p (user=%p)\n", __func__, wsi, wsi->user_space);
return user_callback_handle_rxflow(wsi->protocol->callback, context,
wsi, (enum libwebsocket_callback_reasons) n,
wsi, (enum lws_callback_reasons) n,
wsi->user_space, NULL, 0);
}
int
lws_handle_POLLOUT_event(struct libwebsocket_context *context,
struct libwebsocket *wsi, struct libwebsocket_pollfd *pollfd)
lws_handle_POLLOUT_event(struct lws_context *context,
struct lws *wsi, struct lws_pollfd *pollfd)
{
int n;
struct lws_tokens eff_buf;
#ifdef LWS_USE_HTTP2
struct libwebsocket *wsi2;
struct lws *wsi2;
#endif
int ret;
int m;
@ -280,8 +280,8 @@ notify:
int
lws_service_timeout_check(struct libwebsocket_context *context,
struct libwebsocket *wsi, unsigned int sec)
lws_service_timeout_check(struct lws_context *context,
struct lws *wsi, unsigned int sec)
{
/*
* if extensions want in on it (eg, we are a mux parent)
@ -315,7 +315,7 @@ lws_service_timeout_check(struct libwebsocket_context *context,
return 0;
}
int lws_rxflow_cache(struct libwebsocket *wsi, unsigned char *buf, int n, int len)
int lws_rxflow_cache(struct lws *wsi, unsigned char *buf, int n, int len)
{
/* his RX is flowcontrolled, don't send remaining now */
if (wsi->rxflow_buffer) {
@ -342,13 +342,13 @@ int lws_rxflow_cache(struct libwebsocket *wsi, unsigned char *buf, int n, int le
*
* This function takes a pollfd that has POLLIN or POLLOUT activity and
* services it according to the state of the associated
* struct libwebsocket.
* struct lws.
*
* The one call deals with all "service" that might happen on a socket
* including listen accepts, http files as well as websocket protocol.
*
* If a pollfd says it has something, you can just pass it to
* libwebsocket_serice_fd() whether it is a socket handled by lws or not.
* lws_service_fd() whether it is a socket handled by lws or not.
* If it sees it is a lws socket, the traffic will be handled and
* pollfd->revents will be zeroed now.
*
@ -358,10 +358,10 @@ int lws_rxflow_cache(struct libwebsocket *wsi, unsigned char *buf, int n, int le
*/
LWS_VISIBLE int
lws_service_fd(struct libwebsocket_context *context,
struct libwebsocket_pollfd *pollfd)
lws_service_fd(struct lws_context *context,
struct lws_pollfd *pollfd)
{
struct libwebsocket *wsi;
struct lws *wsi;
int n, m;
lws_sockfd_type mfd;
#if LWS_POSIX
@ -675,7 +675,7 @@ handled:
*/
LWS_VISIBLE int
lws_service(struct libwebsocket_context *context, int timeout_ms)
lws_service(struct lws_context *context, int timeout_ms)
{
return lws_plat_service(context, timeout_ms);
}

View file

@ -86,7 +86,7 @@ static int alpn_cb(SSL *s, const unsigned char **out,
#endif
LWS_VISIBLE void
lws_context_init_http2_ssl(struct libwebsocket_context *context)
lws_context_init_http2_ssl(struct lws_context *context)
{
#if OPENSSL_VERSION_NUMBER >= 0x10002000L
static struct alpn_ctx protos = { (unsigned char *)
@ -106,7 +106,7 @@ lws_context_init_http2_ssl(struct libwebsocket_context *context)
#endif // OPENSSL_VERSION_NUMBER >= 0x10002000L
}
void lws_http2_configure_if_upgraded(struct libwebsocket *wsi)
void lws_http2_configure_if_upgraded(struct lws *wsi)
{
#if OPENSSL_VERSION_NUMBER >= 0x10002000L
struct allocated_headers *ah;

View file

@ -57,7 +57,7 @@ OpenSSL_verify_callback(int preverify_ok, X509_STORE_CTX *x509_ctx)
{
SSL *ssl;
int n;
struct libwebsocket_context *context;
struct lws_context *context;
ssl = X509_STORE_CTX_get_ex_data(x509_ctx,
SSL_get_ex_data_X509_STORE_CTX_idx());
@ -78,7 +78,7 @@ OpenSSL_verify_callback(int preverify_ok, X509_STORE_CTX *x509_ctx)
LWS_VISIBLE int
lws_context_init_server_ssl(struct lws_context_creation_info *info,
struct libwebsocket_context *context)
struct lws_context *context)
{
SSL_METHOD *method;
int error;
@ -246,7 +246,7 @@ lws_context_init_server_ssl(struct lws_context_creation_info *info,
#endif
LWS_VISIBLE void
lws_ssl_destroy(struct libwebsocket_context *context)
lws_ssl_destroy(struct lws_context *context)
{
if (context->ssl_ctx)
SSL_CTX_free(context->ssl_ctx);
@ -278,7 +278,7 @@ lws_decode_ssl_error(void)
#ifndef LWS_NO_CLIENT
int lws_context_init_client_ssl(struct lws_context_creation_info *info,
struct libwebsocket_context *context)
struct lws_context *context)
{
int error;
int n;
@ -406,8 +406,8 @@ int lws_context_init_client_ssl(struct lws_context_creation_info *info,
#endif
LWS_VISIBLE void
lws_ssl_remove_wsi_from_buffered_list(struct libwebsocket_context *context,
struct libwebsocket *wsi)
lws_ssl_remove_wsi_from_buffered_list(struct lws_context *context,
struct lws *wsi)
{
if (!wsi->pending_read_list_prev &&
!wsi->pending_read_list_next &&
@ -432,8 +432,8 @@ lws_ssl_remove_wsi_from_buffered_list(struct libwebsocket_context *context,
}
LWS_VISIBLE int
lws_ssl_capable_read(struct libwebsocket_context *context,
struct libwebsocket *wsi, unsigned char *buf, int len)
lws_ssl_capable_read(struct lws_context *context,
struct lws *wsi, unsigned char *buf, int len)
{
int n;
@ -477,7 +477,7 @@ lwsl_err("%s: LWS_SSL_CAPABLE_ERROR\n", __func__);
}
LWS_VISIBLE int
lws_ssl_pending(struct libwebsocket *wsi)
lws_ssl_pending(struct lws *wsi)
{
if (!wsi->ssl)
return 0;
@ -486,7 +486,7 @@ lws_ssl_pending(struct libwebsocket *wsi)
}
LWS_VISIBLE int
lws_ssl_capable_write(struct libwebsocket *wsi, unsigned char *buf, int len)
lws_ssl_capable_write(struct lws *wsi, unsigned char *buf, int len)
{
int n;
@ -508,7 +508,7 @@ lwsl_err("%s: LWS_SSL_CAPABLE_ERROR\n", __func__);
}
LWS_VISIBLE int
lws_ssl_close(struct libwebsocket *wsi)
lws_ssl_close(struct lws *wsi)
{
int n;
@ -525,12 +525,12 @@ lws_ssl_close(struct libwebsocket *wsi)
}
LWS_VISIBLE int
lws_server_socket_service_ssl(struct libwebsocket_context *context,
struct libwebsocket **pwsi, struct libwebsocket *new_wsi,
int accept_fd, struct libwebsocket_pollfd *pollfd)
lws_server_socket_service_ssl(struct lws_context *context,
struct lws **pwsi, struct lws *new_wsi,
int accept_fd, struct lws_pollfd *pollfd)
{
int n, m;
struct libwebsocket *wsi = *pwsi;
struct lws *wsi = *pwsi;
#ifndef USE_WOLFSSL
BIO *bio;
#endif
@ -711,7 +711,7 @@ fail:
}
LWS_VISIBLE void
lws_ssl_context_destroy(struct libwebsocket_context *context)
lws_ssl_context_destroy(struct lws_context *context)
{
if (context->ssl_ctx)
SSL_CTX_free(context->ssl_ctx);

File diff suppressed because it is too large Load diff

View file

@ -37,7 +37,7 @@ static unsigned int opts;
static int was_closed;
static int deny_deflate;
static int deny_mux;
static struct libwebsocket *wsi_mirror;
static struct lws *wsi_mirror;
static int mirror_lifetime = 0;
static volatile int force_exit = 0;
static int longlived = 0;
@ -68,9 +68,9 @@ enum demo_protocols {
/* dumb_increment protocol */
static int
callback_dumb_increment(struct libwebsocket_context *this,
struct libwebsocket *wsi,
enum libwebsocket_callback_reasons reason,
callback_dumb_increment(struct lws_context *this,
struct lws *wsi,
enum lws_callback_reasons reason,
void *user, void *in, size_t len)
{
switch (reason) {
@ -124,9 +124,9 @@ callback_dumb_increment(struct libwebsocket_context *this,
static int
callback_lws_mirror(struct libwebsocket_context *context,
struct libwebsocket *wsi,
enum libwebsocket_callback_reasons reason,
callback_lws_mirror(struct lws_context *context,
struct lws *wsi,
enum lws_callback_reasons reason,
void *user, void *in, size_t len)
{
unsigned char buf[LWS_SEND_BUFFER_PRE_PADDING + 4096 +
@ -215,7 +215,7 @@ callback_lws_mirror(struct libwebsocket_context *context,
/* list of supported protocols and callbacks */
static struct libwebsocket_protocols protocols[] = {
static struct lws_protocols protocols[] = {
{
"dumb-increment-protocol,fake-nonexistant-protocol",
callback_dumb_increment,
@ -255,9 +255,9 @@ int main(int argc, char **argv)
int ret = 0;
int port = 7681;
int use_ssl = 0;
struct libwebsocket_context *context;
struct lws_context *context;
const char *address;
struct libwebsocket *wsi_dumb;
struct lws *wsi_dumb;
int ietf_version = -1; /* latest */
struct lws_context_creation_info info;

View file

@ -53,9 +53,9 @@ struct per_session_data__echo {
};
static int
callback_echo(struct libwebsocket_context *context,
struct libwebsocket *wsi,
enum libwebsocket_callback_reasons reason, void *user,
callback_echo(struct lws_context *context,
struct lws *wsi,
enum lws_callback_reasons reason, void *user,
void *in, size_t len)
{
struct per_session_data__echo *pss = (struct per_session_data__echo *)user;
@ -145,7 +145,7 @@ do_rx:
static struct libwebsocket_protocols protocols[] = {
static struct lws_protocols protocols[] = {
/* first protocol must always be HTTP handler */
{
@ -189,7 +189,7 @@ int main(int argc, char **argv)
int n = 0;
int port = 7681;
int use_ssl = 0;
struct libwebsocket_context *context;
struct lws_context *context;
int opts = 0;
char interface_name[128] = "";
const char *_interface = NULL;
@ -207,7 +207,7 @@ int main(int argc, char **argv)
char address[256], ads_port[256 + 30];
int rate_us = 250000;
unsigned long long oldus;
struct libwebsocket *wsi;
struct lws *wsi;
int disallow_selfsigned = 0;
struct timeval tv;
#endif

View file

@ -53,9 +53,9 @@ struct per_session_data__fraggle {
};
static int
callback_fraggle(struct libwebsocket_context *context,
struct libwebsocket *wsi,
enum libwebsocket_callback_reasons reason,
callback_fraggle(struct lws_context *context,
struct lws *wsi,
enum lws_callback_reasons reason,
void *user, void *in, size_t len)
{
int n;
@ -232,7 +232,7 @@ callback_fraggle(struct libwebsocket_context *context,
/* list of supported protocols and callbacks */
static struct libwebsocket_protocols protocols[] = {
static struct lws_protocols protocols[] = {
{
"fraggle-protocol",
callback_fraggle,
@ -258,11 +258,11 @@ int main(int argc, char **argv)
int n = 0;
int port = 7681;
int use_ssl = 0;
struct libwebsocket_context *context;
struct lws_context *context;
int opts = 0;
char interface_name[128] = "";
const char *iface = NULL;
struct libwebsocket *wsi;
struct lws *wsi;
const char *address;
int server_port = port;
struct lws_context_creation_info info;

View file

@ -48,7 +48,7 @@
#define MAX_PING_CLIENTS 256
#define PING_RINGBUFFER_SIZE 256
static struct libwebsocket *ping_wsi[MAX_PING_CLIENTS];
static struct lws *ping_wsi[MAX_PING_CLIENTS];
static unsigned int interval_us = 1000000;
static unsigned int size = 64;
static int flood;
@ -100,9 +100,9 @@ enum demo_protocols {
static int
callback_lws_mirror(struct libwebsocket_context * this,
struct libwebsocket *wsi,
enum libwebsocket_callback_reasons reason,
callback_lws_mirror(struct lws_context * this,
struct lws *wsi,
enum lws_callback_reasons reason,
void *user, void *in, size_t len)
{
struct timeval tv;
@ -286,7 +286,7 @@ callback_lws_mirror(struct libwebsocket_context * this,
/* list of supported protocols and callbacks */
static struct libwebsocket_protocols protocols[] = {
static struct lws_protocols protocols[] = {
{
"lws-mirror-protocol",
@ -330,7 +330,7 @@ int main(int argc, char **argv)
int n = 0;
int port = 7681;
int use_ssl = 0;
struct libwebsocket_context *context;
struct lws_context *context;
char protocol_name[256];
char ip[30];
#ifndef _WIN32

View file

@ -23,9 +23,9 @@
/* dumb_increment protocol */
int
callback_dumb_increment(struct libwebsocket_context *context,
struct libwebsocket *wsi,
enum libwebsocket_callback_reasons reason,
callback_dumb_increment(struct lws_context *context,
struct lws *wsi,
enum lws_callback_reasons reason,
void *user, void *in, size_t len)
{
unsigned char buf[LWS_SEND_BUFFER_PRE_PADDING + 512 +

View file

@ -60,7 +60,7 @@ struct serveable {
* content
*/
void
dump_handshake_info(struct libwebsocket *wsi)
dump_handshake_info(struct lws *wsi)
{
int n = 0;
char buf[256];
@ -110,10 +110,9 @@ const char * get_mimetype(const char *file)
* here on the first protocol server.
*/
int callback_http(struct libwebsocket_context *context,
struct libwebsocket *wsi,
enum libwebsocket_callback_reasons reason, void *user,
void *in, size_t len)
int callback_http(struct lws_context *context, struct lws *wsi,
enum lws_callback_reasons reason, void *user,
void *in, size_t len)
{
struct per_session_data__http *pss =
(struct per_session_data__http *)user;
@ -130,7 +129,7 @@ int callback_http(struct libwebsocket_context *context,
int n, m;
#ifdef EXTERNAL_POLL
struct libwebsocket_pollargs *pa = (struct libwebsocket_pollargs *)in;
struct lws_pollargs *pa = (struct lws_pollargs *)in;
#endif
switch (reason) {

View file

@ -33,9 +33,9 @@ static struct a_message ringbuffer[MAX_MESSAGE_QUEUE];
static int ringbuffer_head;
int
callback_lws_mirror(struct libwebsocket_context *context,
struct libwebsocket *wsi,
enum libwebsocket_callback_reasons reason,
callback_lws_mirror(struct lws_context *context,
struct lws *wsi,
enum lws_callback_reasons reason,
void *user, void *in, size_t len)
{
struct per_session_data__lws_mirror *pss =

View file

@ -26,12 +26,12 @@ int close_testing;
int max_poll_elements;
#ifdef EXTERNAL_POLL
struct libwebsocket_pollfd *pollfds;
struct lws_pollfd *pollfds;
int *fd_lookup;
int count_pollfds;
#endif
volatile int force_exit = 0;
struct libwebsocket_context *context;
struct lws_context *context;
/*
* This mutex lock protects code that changes or relies on wsi list outside of
@ -90,7 +90,7 @@ enum demo_protocols {
/* list of supported protocols and callbacks */
static struct libwebsocket_protocols protocols[] = {
static struct lws_protocols protocols[] = {
/* first protocol must always be HTTP handler */
{
@ -265,7 +265,7 @@ int main(int argc, char **argv)
printf("Using resource path \"%s\"\n", resource_path);
#ifdef EXTERNAL_POLL
max_poll_elements = getdtablesize();
pollfds = malloc(max_poll_elements * sizeof (struct libwebsocket_pollfd));
pollfds = malloc(max_poll_elements * sizeof (struct lws_pollfd));
fd_lookup = malloc(max_poll_elements * sizeof (int));
if (pollfds == NULL || fd_lookup == NULL) {
lwsl_err("Out of memory pollfds=%d\n", max_poll_elements);

View file

@ -25,12 +25,12 @@ int close_testing;
int max_poll_elements;
#ifdef EXTERNAL_POLL
struct libwebsocket_pollfd *pollfds;
struct lws_pollfd *pollfds;
int *fd_lookup;
int count_pollfds;
#endif
volatile int force_exit = 0;
struct libwebsocket_context *context;
struct lws_context *context;
/* http server gets files from this path */
#define LOCAL_RESOURCE_PATH INSTALL_DATADIR"/libwebsockets-test-server"
@ -73,7 +73,7 @@ enum demo_protocols {
/* list of supported protocols and callbacks */
static struct libwebsocket_protocols protocols[] = {
static struct lws_protocols protocols[] = {
/* first protocol must always be HTTP handler */
{
@ -227,7 +227,7 @@ int main(int argc, char **argv)
printf("Using resource path \"%s\"\n", resource_path);
#ifdef EXTERNAL_POLL
max_poll_elements = getdtablesize();
pollfds = malloc(max_poll_elements * sizeof (struct libwebsocket_pollfd));
pollfds = malloc(max_poll_elements * sizeof (struct lws_pollfd));
fd_lookup = malloc(max_poll_elements * sizeof (int));
if (pollfds == NULL || fd_lookup == NULL) {
lwsl_err("Out of memory pollfds=%d\n", max_poll_elements);

View file

@ -27,12 +27,12 @@ extern int close_testing;
extern int max_poll_elements;
#ifdef EXTERNAL_POLL
extern struct libwebsocket_pollfd *pollfds;
extern struct lws_pollfd *pollfds;
extern int *fd_lookup;
extern int count_pollfds;
#endif
extern volatile int force_exit;
extern struct libwebsocket_context *context;
extern struct lws_context *context;
extern char *resource_path;
extern void test_server_lock(int care);
@ -59,22 +59,22 @@ struct per_session_data__dumb_increment {
};
struct per_session_data__lws_mirror {
struct libwebsocket *wsi;
struct lws *wsi;
int ringbuffer_tail;
};
extern int callback_http(struct libwebsocket_context *context,
struct libwebsocket *wsi,
enum libwebsocket_callback_reasons reason,
extern int callback_http(struct lws_context *context,
struct lws *wsi,
enum lws_callback_reasons reason,
void *user, void *in, size_t len);
extern int callback_lws_mirror(struct libwebsocket_context *context,
struct libwebsocket *wsi,
enum libwebsocket_callback_reasons reason,
extern int callback_lws_mirror(struct lws_context *context,
struct lws *wsi,
enum lws_callback_reasons reason,
void *user, void *in, size_t len);
extern int callback_dumb_increment(struct libwebsocket_context *context,
struct libwebsocket *wsi,
enum libwebsocket_callback_reasons reason,
extern int callback_dumb_increment(struct lws_context *context,
struct lws *wsi,
enum lws_callback_reasons reason,
void *user, void *in, size_t len);
extern void
dump_handshake_info(struct libwebsocket *wsi);
dump_handshake_info(struct lws *wsi);