diff --git a/lib/client-handshake.c b/lib/client-handshake.c
index 3a8de9b1..8bfec2d2 100644
--- a/lib/client-handshake.c
+++ b/lib/client-handshake.c
@@ -1,6 +1,6 @@
#include "private-libwebsockets.h"
-struct libwebsocket *libwebsocket_client_connect_2(
+struct libwebsocket *lws_client_connect_2(
struct libwebsocket_context *context,
struct libwebsocket *wsi
) {
@@ -18,7 +18,7 @@ struct libwebsocket *libwebsocket_client_connect_2(
int plen = 0;
const char *ads;
- lwsl_client("libwebsocket_client_connect_2\n");
+ lwsl_client("lws_client_connect_2\n");
/*
* proxy?
@@ -169,7 +169,7 @@ struct libwebsocket *libwebsocket_client_connect_2(
* handling as oom4 does. We have to run the whole close flow.
*/
- libwebsocket_set_timeout(wsi,
+ lws_set_timeout(wsi,
PENDING_TIMEOUT_AWAITING_CONNECT_RESPONSE,
AWAITING_TIMEOUT);
#ifdef LWS_USE_IPV6
@@ -266,7 +266,7 @@ struct libwebsocket *libwebsocket_client_connect_2(
goto failed;
}
- libwebsocket_set_timeout(wsi,
+ lws_set_timeout(wsi,
PENDING_TIMEOUT_AWAITING_PROXY_RESPONSE,
AWAITING_TIMEOUT);
@@ -285,14 +285,14 @@ struct libwebsocket *libwebsocket_client_connect_2(
* cover with a timeout.
*/
- libwebsocket_set_timeout(wsi,
+ lws_set_timeout(wsi,
PENDING_TIMEOUT_SENT_CLIENT_HANDSHAKE, AWAITING_TIMEOUT);
wsi->mode = LWS_CONNMODE_WS_CLIENT_ISSUE_HANDSHAKE;
pfd.fd = wsi->sock;
pfd.revents = LWS_POLLIN;
- n = libwebsocket_service_fd(context, &pfd);
+ n = lws_service_fd(context, &pfd);
if (n < 0)
goto failed;
@@ -314,7 +314,7 @@ failed:
}
/**
- * libwebsocket_client_connect() - Connect to another websocket server
+ * lws_client_connect() - Connect to another websocket server
* @context: Websocket context
* @address: Remote server address, eg, "myserver.com"
* @port: Port to connect to on the remote server, eg, 80
@@ -334,7 +334,7 @@ failed:
*/
LWS_VISIBLE struct libwebsocket *
-libwebsocket_client_connect(struct libwebsocket_context *context,
+lws_client_connect(struct libwebsocket_context *context,
const char *address,
int port,
int ssl_connection,
@@ -416,18 +416,18 @@ libwebsocket_client_connect(struct libwebsocket_context *context,
if (lws_ext_callback_for_each_extension_type(context, wsi,
LWS_EXT_CALLBACK_CAN_PROXY_CLIENT_CONNECTION,
(void *)address, port) > 0) {
- lwsl_client("libwebsocket_client_connect: ext handling conn\n");
+ lwsl_client("lws_client_connect: ext handling conn\n");
- libwebsocket_set_timeout(wsi,
+ lws_set_timeout(wsi,
PENDING_TIMEOUT_AWAITING_EXTENSION_CONNECT_RESPONSE,
AWAITING_TIMEOUT);
wsi->mode = LWS_CONNMODE_WS_CLIENT_WAITING_EXTENSION_CONNECT;
return wsi;
}
- lwsl_client("libwebsocket_client_connect: direct conn\n");
+ lwsl_client("lws_client_connect: direct conn\n");
- return libwebsocket_client_connect_2(context, wsi);
+ return lws_client_connect_2(context, wsi);
bail1:
lws_free(wsi->u.hdr.ah);
@@ -439,7 +439,7 @@ bail:
/**
- * libwebsocket_client_connect_extended() - Connect to another websocket server
+ * lws_client_connect_extended() - Connect to another websocket server
* @context: Websocket context
* @address: Remote server address, eg, "myserver.com"
* @port: Port to connect to on the remote server, eg, 80
@@ -459,7 +459,7 @@ bail:
*/
LWS_VISIBLE struct libwebsocket *
-libwebsocket_client_connect_extended(struct libwebsocket_context *context,
+lws_client_connect_extended(struct libwebsocket_context *context,
const char *address,
int port,
int ssl_connection,
@@ -471,7 +471,7 @@ libwebsocket_client_connect_extended(struct libwebsocket_context *context,
void *userdata)
{
struct libwebsocket *ws =
- libwebsocket_client_connect(context, address, port,
+ lws_client_connect(context, address, port,
ssl_connection, path, host, origin, protocol,
ietf_version_or_minus_one);
diff --git a/lib/client-parser.c b/lib/client-parser.c
index 30fc47d0..567f5cac 100644
--- a/lib/client-parser.c
+++ b/lib/client-parser.c
@@ -277,7 +277,7 @@ spill:
* we do not care about how it went, we are closing
* immediately afterwards
*/
- libwebsocket_write(wsi, (unsigned char *)
+ lws_write(wsi, (unsigned char *)
&wsi->u.ws.rx_user_buffer[
LWS_SEND_BUFFER_PRE_PADDING],
wsi->u.ws.rx_user_buffer_head, LWS_WRITE_CLOSE);
@@ -326,7 +326,7 @@ spill:
wsi->u.ws.ping_pending_flag = 1;
/* get it sent as soon as possible */
- libwebsocket_callback_on_writable(wsi->protocol->owning_server, wsi);
+ lws_callback_on_writable(wsi->protocol->owning_server, wsi);
ping_drop:
wsi->u.ws.rx_user_buffer_head = 0;
handled = 1;
@@ -378,7 +378,7 @@ ping_drop:
/*
* No it's real payload, pass it up to the user callback.
* It's nicely buffered with the pre-padding taken care of
- * so it can be sent straight out again using libwebsocket_write
+ * so it can be sent straight out again using lws_write
*/
if (handled)
goto already_done;
diff --git a/lib/client.c b/lib/client.c
index d1ad93ec..29ee3c95 100644
--- a/lib/client.c
+++ b/lib/client.c
@@ -60,7 +60,7 @@ int lws_client_socket_service(struct libwebsocket_context *context,
* timeout protection set in client-handshake.c
*/
- if (libwebsocket_client_connect_2(context, wsi) == NULL) {
+ if (lws_client_connect_2(context, wsi) == NULL) {
/* closed */
lwsl_client("closed\n");
return -1;
@@ -111,7 +111,7 @@ int lws_client_socket_service(struct libwebsocket_context *context,
/* clear his proxy connection timeout */
- libwebsocket_set_timeout(wsi, NO_PENDING_TIMEOUT, 0);
+ lws_set_timeout(wsi, NO_PENDING_TIMEOUT, 0);
/* fallthru */
@@ -123,7 +123,7 @@ int lws_client_socket_service(struct libwebsocket_context *context,
*/
/*
- * take care of our libwebsocket_callback_on_writable
+ * take care of our lws_callback_on_writable
* happening at a time when there's no real connection yet
*/
if (lws_change_pollfd(wsi, LWS_POLLOUT, 0))
@@ -234,7 +234,7 @@ int lws_client_socket_service(struct libwebsocket_context *context,
lwsl_info(
"SSL_connect WANT_WRITE... retrying\n");
- libwebsocket_callback_on_writable(
+ lws_callback_on_writable(
context, wsi);
some_wait:
wsi->mode = LWS_CONNMODE_WS_CLIENT_WAITING_SSL;
@@ -296,7 +296,7 @@ some_wait:
*/
lwsl_info("SSL_connect WANT_WRITE... retrying\n");
- libwebsocket_callback_on_writable(context, wsi);
+ lws_callback_on_writable(context, wsi);
goto some_wait;
}
@@ -347,7 +347,7 @@ some_wait:
#endif
wsi->mode = LWS_CONNMODE_WS_CLIENT_ISSUE_HANDSHAKE2;
- libwebsocket_set_timeout(wsi,
+ lws_set_timeout(wsi,
PENDING_TIMEOUT_AWAITING_CLIENT_HS_SEND,
AWAITING_TIMEOUT);
@@ -375,14 +375,14 @@ some_wait:
LWS_CLOSE_STATUS_NOSTATUS);
return 0;
case LWS_SSL_CAPABLE_MORE_SERVICE:
- libwebsocket_callback_on_writable(context, wsi);
+ lws_callback_on_writable(context, wsi);
break;
}
wsi->u.hdr.parser_state = WSI_TOKEN_NAME_PART;
wsi->u.hdr.lextable_pos = 0;
wsi->mode = LWS_CONNMODE_WS_CLIENT_WAITING_SERVER_REPLY;
- libwebsocket_set_timeout(wsi,
+ lws_set_timeout(wsi,
PENDING_TIMEOUT_AWAITING_SERVER_RESPONSE,
AWAITING_TIMEOUT);
break;
@@ -740,7 +740,7 @@ check_accept:
/* clear his proxy connection timeout */
- libwebsocket_set_timeout(wsi, NO_PENDING_TIMEOUT, 0);
+ lws_set_timeout(wsi, NO_PENDING_TIMEOUT, 0);
/* free up his parsing allocations */
@@ -849,7 +849,7 @@ libwebsockets_generate_client_handshake(struct libwebsocket_context *context,
* create the random key
*/
- n = libwebsockets_get_random(context, hash, 16);
+ n = lws_get_random(context, hash, 16);
if (n != 16) {
lwsl_err("Unable to read from random dev %s\n",
SYSTEM_RANDOM_FILEPATH);
@@ -968,7 +968,7 @@ libwebsockets_generate_client_handshake(struct libwebsocket_context *context,
key_b64[39] = '\0'; /* enforce composed length below buf sizeof */
n = sprintf(buf, "%s258EAFA5-E914-47DA-95CA-C5AB0DC85B11", key_b64);
- libwebsockets_SHA1((unsigned char *)buf, n, (unsigned char *)hash);
+ lws_SHA1((unsigned char *)buf, n, (unsigned char *)hash);
lws_b64_encode_string(hash, 20,
wsi->u.hdr.ah->initial_handshake_hash_base64,
diff --git a/lib/context.c b/lib/context.c
index 1a418a62..71154a14 100644
--- a/lib/context.c
+++ b/lib/context.c
@@ -42,7 +42,7 @@ lws_get_library_version(void)
}
/**
- * libwebsocket_create_context() - Create the websocket handler
+ * lws_create_context() - Create the websocket handler
* @info: pointer to struct with parameters
*
* This function creates the listening socket (if serving) and takes care
@@ -50,7 +50,7 @@ lws_get_library_version(void)
*
* After initialization, it returns a struct libwebsocket_context * that
* represents this server. After calling, user code needs to take care
- * of calling libwebsocket_service() with the context pointer to get the
+ * of calling lws_service() with the context pointer to get the
* server's sockets serviced. This must be done in the same process
* context as the initialization call.
*
@@ -72,7 +72,7 @@ lws_get_library_version(void)
*/
LWS_VISIBLE struct libwebsocket_context *
-libwebsocket_create_context(struct lws_context_creation_info *info)
+lws_create_context(struct lws_context_creation_info *info)
{
struct libwebsocket_context *context = NULL;
char *p;
@@ -138,12 +138,12 @@ libwebsocket_create_context(struct lws_context_creation_info *info)
#ifdef LWS_USE_LIBEV
/* (Issue #264) In order to *avoid breaking backwards compatibility*, we
* enable libev mediated SIGINT handling with a default handler of
- * libwebsocket_sigint_cb. The handler can be overridden or disabled
- * by invoking libwebsocket_sigint_cfg after creating the context, but
- * before invoking libwebsocket_initloop:
+ * lws_sigint_cb. The handler can be overridden or disabled
+ * by invoking lws_sigint_cfg after creating the context, but
+ * before invoking lws_initloop:
*/
context->use_ev_sigint = 1;
- context->lws_ev_sigint_cb = &libwebsocket_sigint_cb;
+ context->lws_ev_sigint_cb = &lws_sigint_cb;
#endif /* LWS_USE_LIBEV */
/* to reduce this allocation, */
@@ -166,13 +166,11 @@ libwebsocket_create_context(struct lws_context_creation_info *info)
goto bail;
}
- if (lws_plat_init_lookup(context)) {
+ if (lws_plat_init_lookup(context))
goto bail;
- }
- if (lws_plat_init_fd_tables(context)) {
+ if (lws_plat_init_fd_tables(context))
goto bail;
- }
lws_context_init_extensions(info, context);
@@ -188,12 +186,12 @@ libwebsocket_create_context(struct lws_context_creation_info *info)
/* override for backwards compatibility */
if (info->http_proxy_port)
context->http_proxy_port = info->http_proxy_port;
- libwebsocket_set_proxy(context, info->http_proxy_address);
+ lws_set_proxy(context, info->http_proxy_address);
} else {
#ifdef LWS_HAVE_GETENV
p = getenv("http_proxy");
if (p)
- libwebsocket_set_proxy(context, p);
+ lws_set_proxy(context, p);
#endif
}
@@ -259,12 +257,12 @@ libwebsocket_create_context(struct lws_context_creation_info *info)
return context;
bail:
- libwebsocket_context_destroy(context);
+ lws_context_destroy(context);
return NULL;
}
/**
- * libwebsocket_context_destroy() - Destroy the websocket context
+ * lws_context_destroy() - Destroy the websocket context
* @context: Websocket context
*
* This function closes any active connections and then frees the
@@ -272,7 +270,7 @@ bail:
* undefined.
*/
LWS_VISIBLE void
-libwebsocket_context_destroy(struct libwebsocket_context *context)
+lws_context_destroy(struct libwebsocket_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 */
diff --git a/lib/extension.c b/lib/extension.c
index b7a5792b..7451ba2d 100644
--- a/lib/extension.c
+++ b/lib/extension.c
@@ -35,7 +35,7 @@ lws_context_init_extensions(struct lws_context_creation_info *info,
lwsl_info(" LWS_MAX_EXTENSIONS_ACTIVE: %u\n", LWS_MAX_EXTENSIONS_ACTIVE);
}
-LWS_VISIBLE struct libwebsocket_extension *libwebsocket_get_internal_extensions()
+LWS_VISIBLE struct libwebsocket_extension *lws_get_internal_extensions()
{
return libwebsocket_internal_extensions;
}
@@ -175,7 +175,7 @@ lws_issue_raw_ext_access(struct libwebsocket *wsi,
* Yes, he's choked. Don't spill the rest now get a callback
* when he is ready to send and take care of it there
*/
- libwebsocket_callback_on_writable(
+ lws_callback_on_writable(
wsi->protocol->owning_server, wsi);
wsi->extension_data_pending = 1;
ret = 0;
diff --git a/lib/handshake.c b/lib/handshake.c
index 07afb6be..d1e3f9cd 100644
--- a/lib/handshake.c
+++ b/lib/handshake.c
@@ -57,7 +57,7 @@
*/
LWS_VISIBLE int
-libwebsocket_read(struct libwebsocket_context *context,
+lws_read(struct libwebsocket_context *context,
struct libwebsocket *wsi, unsigned char *buf, size_t len)
{
size_t n;
@@ -127,7 +127,7 @@ http_new:
wsi->u.http.content_remain = wsi->u.http.content_length;
if (!wsi->u.http.content_remain) {
/* there is no POST content */
- libwebsocket_set_timeout(wsi, NO_PENDING_TIMEOUT, 0);
+ lws_set_timeout(wsi, NO_PENDING_TIMEOUT, 0);
if (wsi->protocol->callback) {
n = wsi->protocol->callback(
wsi->protocol->owning_server, wsi,
@@ -167,7 +167,7 @@ http_postbody:
if (!wsi->u.http.content_remain) {
/* he sent the content in time */
- libwebsocket_set_timeout(wsi, NO_PENDING_TIMEOUT, 0);
+ lws_set_timeout(wsi, NO_PENDING_TIMEOUT, 0);
if (wsi->protocol->callback) {
n = wsi->protocol->callback(
wsi->protocol->owning_server, wsi,
@@ -178,7 +178,7 @@ http_postbody:
}
goto http_complete;
} else
- libwebsocket_set_timeout(wsi,
+ lws_set_timeout(wsi,
PENDING_TIMEOUT_HTTP_CONTENT,
AWAITING_TIMEOUT);
}
@@ -199,18 +199,18 @@ http_postbody:
}
break;
default:
- lwsl_err("libwebsocket_read: Unhandled state\n");
+ lwsl_err("lws_read: Unhandled state\n");
break;
}
read_ok:
/* Nothing more to do for now. */
- lwsl_debug("libwebsocket_read: read_ok\n");
+ lwsl_debug("lws_read: read_ok\n");
return 0;
http_complete:
- lwsl_debug("libwebsocket_read: http_complete\n");
+ lwsl_debug("lws_read: http_complete\n");
#ifndef LWS_NO_SERVER
/* Did the client want to keep the HTTP connection going? */
@@ -224,7 +224,7 @@ http_complete:
return 0;
bail:
- lwsl_debug("closing connection at libwebsocket_read bail:\n");
+ lwsl_debug("closing connection at lws_read bail:\n");
libwebsocket_close_and_free_session(context, wsi,
LWS_CLOSE_STATUS_NOSTATUS);
diff --git a/lib/header.c b/lib/header.c
index 56c8fc05..d9747376 100644
--- a/lib/header.c
+++ b/lib/header.c
@@ -172,7 +172,7 @@ int lws_add_http_header_status(struct libwebsocket_context *context,
}
/**
- * libwebsockets_return_http_status() - Return simple http status
+ * lws_return_http_status() - Return simple http status
* @context: libwebsockets context
* @wsi: Websocket instance (available from user callback)
* @code: Status index, eg, 404
@@ -181,7 +181,7 @@ int lws_add_http_header_status(struct libwebsocket_context *context,
* Helper to report HTTP errors back to the client cleanly and
* consistently
*/
-LWS_VISIBLE int libwebsockets_return_http_status(
+LWS_VISIBLE int lws_return_http_status(
struct libwebsocket_context *context, struct libwebsocket *wsi,
unsigned int code, const char *html_body)
{
@@ -204,12 +204,12 @@ LWS_VISIBLE int libwebsockets_return_http_status(
if (lws_finalize_http_header(context, wsi, &p, end))
return 1;
- m = libwebsocket_write(wsi, start, p - start, LWS_WRITE_HTTP_HEADERS);
+ m = lws_write(wsi, start, p - start, LWS_WRITE_HTTP_HEADERS);
if (m != (int)(p - start))
return 1;
n = sprintf((char *)start, "
%u
%s", code, html_body);
- m = libwebsocket_write(wsi, start, n, LWS_WRITE_HTTP);
+ m = lws_write(wsi, start, n, LWS_WRITE_HTTP);
return m != n;
}
diff --git a/lib/http2.c b/lib/http2.c
index aa2189c7..ffedb785 100644
--- a/lib/http2.c
+++ b/lib/http2.c
@@ -303,7 +303,7 @@ lws_http2_parser(struct libwebsocket_context *context,
if (swsi->u.http2.waiting_tx_credit && swsi->u.http2.tx_credit > 0) {
lwsl_info("%s: %p: waiting_tx_credit -> wait on writeable\n", __func__, wsi);
swsi->u.http2.waiting_tx_credit = 0;
- libwebsocket_callback_on_writable(context, swsi);
+ lws_callback_on_writable(context, swsi);
}
break;
}
diff --git a/lib/libev.c b/lib/libev.c
index 8cda4483..203a0fb9 100644
--- a/lib/libev.c
+++ b/lib/libev.c
@@ -47,17 +47,17 @@ libwebsocket_accept_cb(struct ev_loop *loop, struct ev_io *watcher, int revents)
if (revents & EV_WRITE)
eventfd.revents |= LWS_POLLOUT;
- libwebsocket_service_fd(context, &eventfd);
+ lws_service_fd(context, &eventfd);
}
LWS_VISIBLE void
-libwebsocket_sigint_cb(struct ev_loop *loop,
+lws_sigint_cb(struct ev_loop *loop,
struct ev_signal *watcher, int revents)
{
ev_break(loop, EVBREAK_ALL);
}
-LWS_VISIBLE int libwebsocket_sigint_cfg(
+LWS_VISIBLE int lws_sigint_cfg(
struct libwebsocket_context *context,
int use_ev_sigint,
lws_ev_signal_cb* cb)
@@ -67,13 +67,13 @@ LWS_VISIBLE int libwebsocket_sigint_cfg(
context->lws_ev_sigint_cb = cb;
}
else {
- context->lws_ev_sigint_cb = &libwebsocket_sigint_cb;
+ context->lws_ev_sigint_cb = &lws_sigint_cb;
};
return 0;
};
LWS_VISIBLE int
-libwebsocket_initloop(
+lws_initloop(
struct libwebsocket_context *context,
struct ev_loop *loop)
{
diff --git a/lib/libwebsockets.c b/lib/libwebsockets.c
index cb4a9efd..9cdd29a2 100644
--- a/lib/libwebsockets.c
+++ b/lib/libwebsockets.c
@@ -89,7 +89,7 @@ libwebsocket_close_and_free_session(struct libwebsocket_context *context,
case WSI_STATE_FLUSHING_STORED_SEND_BEFORE_CLOSE:
if (wsi->truncated_send_len) {
- libwebsocket_callback_on_writable(context, wsi);
+ lws_callback_on_writable(context, wsi);
return;
}
lwsl_info("wsi %p completed WSI_STATE_FLUSHING_STORED_SEND_BEFORE_CLOSE\n", wsi);
@@ -98,7 +98,7 @@ libwebsocket_close_and_free_session(struct libwebsocket_context *context,
if (wsi->truncated_send_len) {
lwsl_info("wsi %p entering WSI_STATE_FLUSHING_STORED_SEND_BEFORE_CLOSE\n", wsi);
wsi->state = WSI_STATE_FLUSHING_STORED_SEND_BEFORE_CLOSE;
- libwebsocket_set_timeout(wsi, PENDING_FLUSH_STORED_SEND_BEFORE_CLOSE, 5);
+ lws_set_timeout(wsi, PENDING_FLUSH_STORED_SEND_BEFORE_CLOSE, 5);
return;
}
break;
@@ -172,7 +172,7 @@ libwebsocket_close_and_free_session(struct libwebsocket_context *context,
} while (ret);
/*
- * signal we are closing, libwebsocket_write will
+ * signal we are closing, lws_write will
* add any necessary version-specific stuff. If the write fails,
* no worries we are closing anyway. If we didn't initiate this
* close, then our state has been changed to
@@ -191,7 +191,7 @@ libwebsocket_close_and_free_session(struct libwebsocket_context *context,
/* make valgrind happy */
memset(buf, 0, sizeof(buf));
- n = libwebsocket_write(wsi,
+ n = lws_write(wsi,
&buf[LWS_SEND_BUFFER_PRE_PADDING + 2],
0, LWS_WRITE_CLOSE);
if (n >= 0) {
@@ -207,7 +207,7 @@ libwebsocket_close_and_free_session(struct libwebsocket_context *context,
* out of politeness
*/
- libwebsocket_set_timeout(wsi,
+ lws_set_timeout(wsi,
PENDING_TIMEOUT_CLOSE_ACK, 1);
lwsl_debug("sent close indication, awaiting ack\n");
@@ -406,7 +406,7 @@ libwebsockets_get_addresses(struct libwebsocket_context *context,
}
/**
- * libwebsockets_get_peer_addresses() - Get client address information
+ * lws_get_peer_addresses() - Get client address information
* @context: Libwebsockets context
* @wsi: Local struct libwebsocket associated with
* @fd: Connection socket descriptor
@@ -422,7 +422,7 @@ libwebsockets_get_addresses(struct libwebsocket_context *context,
*/
LWS_VISIBLE void
-libwebsockets_get_peer_addresses(struct libwebsocket_context *context,
+lws_get_peer_addresses(struct libwebsocket_context *context,
struct libwebsocket *wsi, lws_sockfd_type fd, char *name, int name_len,
char *rip, int rip_len)
{
@@ -459,7 +459,7 @@ libwebsockets_get_peer_addresses(struct libwebsocket_context *context,
ret = libwebsockets_get_addresses(context, p, name, name_len, rip, rip_len);
bail:
- lws_latency(context, wsi, "libwebsockets_get_peer_addresses", ret, 1);
+ lws_latency(context, wsi, "lws_get_peer_addresses", ret, 1);
#else
(void)context;
(void)wsi;
@@ -472,7 +472,7 @@ bail:
}
/**
- * libwebsocket_context_user() - get the user data associated with the context
+ * lws_context_user() - get the user data associated with the context
* @context: Websocket context
*
* This returns the optional user allocation that can be attached to
@@ -481,14 +481,14 @@ bail:
* using globals statics in the user code.
*/
LWS_EXTERN void *
-libwebsocket_context_user(struct libwebsocket_context *context)
+lws_context_user(struct libwebsocket_context *context)
{
return context->user_space;
}
/**
- * libwebsocket_callback_all_protocol() - Callback all connections using
+ * lws_callback_all_protocol() - Callback all connections using
* the given protocol with the given reason
*
* @protocol: Protocol whose connections will get callbacks
@@ -496,7 +496,7 @@ libwebsocket_context_user(struct libwebsocket_context *context)
*/
LWS_VISIBLE int
-libwebsocket_callback_all_protocol(
+lws_callback_all_protocol(
const struct libwebsocket_protocols *protocol, int reason)
{
struct libwebsocket_context *context = protocol->owning_server;
@@ -516,7 +516,7 @@ libwebsocket_callback_all_protocol(
}
/**
- * libwebsocket_set_timeout() - marks the wsi as subject to a timeout
+ * lws_set_timeout() - marks the wsi as subject to a timeout
*
* You will not need this unless you are doing something special
*
@@ -526,7 +526,7 @@ libwebsocket_callback_all_protocol(
*/
LWS_VISIBLE void
-libwebsocket_set_timeout(struct libwebsocket *wsi,
+lws_set_timeout(struct libwebsocket *wsi,
enum pending_timeout reason, int secs)
{
time_t now;
@@ -541,7 +541,7 @@ libwebsocket_set_timeout(struct libwebsocket *wsi,
#if LWS_POSIX
/**
- * libwebsocket_get_socket_fd() - returns the socket file descriptor
+ * lws_get_socket_fd() - returns the socket file descriptor
*
* You will not need this unless you are doing something special
*
@@ -549,7 +549,7 @@ libwebsocket_set_timeout(struct libwebsocket *wsi,
*/
LWS_VISIBLE int
-libwebsocket_get_socket_fd(struct libwebsocket *wsi)
+lws_get_socket_fd(struct libwebsocket *wsi)
{
return wsi->sock;
}
@@ -600,7 +600,7 @@ lws_latency(struct libwebsocket_context *context, struct libwebsocket *wsi,
/**
- * libwebsocket_rx_flow_control() - Enable and disable socket servicing for
+ * lws_rx_flow_control() - Enable and disable socket servicing for
* received packets.
*
* If the output side of a server process becomes choked, this allows flow
@@ -611,19 +611,19 @@ lws_latency(struct libwebsocket_context *context, struct libwebsocket *wsi,
*/
LWS_VISIBLE int
-libwebsocket_rx_flow_control(struct libwebsocket *wsi, int enable)
+lws_rx_flow_control(struct libwebsocket *wsi, int enable)
{
if (enable == (wsi->rxflow_change_to & LWS_RXFLOW_ALLOW))
return 0;
- lwsl_info("libwebsocket_rx_flow_control(0x%p, %d)\n", wsi, enable);
+ lwsl_info("lws_rx_flow_control(0x%p, %d)\n", wsi, enable);
wsi->rxflow_change_to = LWS_RXFLOW_PENDING_CHANGE | !!enable;
return 0;
}
/**
- * libwebsocket_rx_flow_allow_all_protocol() - Allow all connections with this protocol to receive
+ * lws_rx_flow_allow_all_protocol() - Allow all connections with this protocol to receive
*
* When the user server code realizes it can accept more input, it can
* call this to have the RX flow restriction removed from all connections using
@@ -633,7 +633,7 @@ libwebsocket_rx_flow_control(struct libwebsocket *wsi, int enable)
*/
LWS_VISIBLE void
-libwebsocket_rx_flow_allow_all_protocol(
+lws_rx_flow_allow_all_protocol(
const struct libwebsocket_protocols *protocol)
{
struct libwebsocket_context *context = protocol->owning_server;
@@ -645,13 +645,13 @@ libwebsocket_rx_flow_allow_all_protocol(
if (!wsi)
continue;
if (wsi->protocol == protocol)
- libwebsocket_rx_flow_control(wsi, LWS_RXFLOW_ALLOW);
+ lws_rx_flow_control(wsi, LWS_RXFLOW_ALLOW);
}
}
/**
- * libwebsocket_canonical_hostname() - returns this host's hostname
+ * lws_canonical_hostname() - returns this host's hostname
*
* This is typically used by client code to fill in the host parameter
* when making a client connection. You can only call it after the context
@@ -660,7 +660,7 @@ libwebsocket_rx_flow_allow_all_protocol(
* @context: Websocket context
*/
LWS_VISIBLE extern const char *
-libwebsocket_canonical_hostname(struct libwebsocket_context *context)
+lws_canonical_hostname(struct libwebsocket_context *context)
{
return (const char *)context->canonical_hostname;
}
@@ -675,14 +675,14 @@ int user_callback_handle_rxflow(callback_function callback_function,
n = callback_function(context, wsi, reason, user, in, len);
if (!n)
- n = _libwebsocket_rx_flow_control(wsi);
+ n = _lws_rx_flow_control(wsi);
return n;
}
/**
- * libwebsocket_set_proxy() - Setups proxy to libwebsocket_context.
+ * lws_set_proxy() - Setups proxy to libwebsocket_context.
* @context: pointer to struct libwebsocket_context you want set proxy to
* @proxy: pointer to c string containing proxy in format address:port
*
@@ -700,7 +700,7 @@ int user_callback_handle_rxflow(callback_function callback_function,
*/
LWS_VISIBLE int
-libwebsocket_set_proxy(struct libwebsocket_context *context, const char *proxy)
+lws_set_proxy(struct libwebsocket_context *context, const char *proxy)
{
char *p;
char authstring[96];
@@ -754,7 +754,7 @@ auth_too_long:
}
/**
- * libwebsockets_get_protocol() - Returns a protocol pointer from a websocket
+ * lws_get_protocol() - Returns a protocol pointer from a websocket
* connection.
* @wsi: pointer to struct websocket you want to know the protocol of
*
@@ -764,19 +764,19 @@ auth_too_long:
*/
LWS_VISIBLE const struct libwebsocket_protocols *
-libwebsockets_get_protocol(struct libwebsocket *wsi)
+lws_get_protocol(struct libwebsocket *wsi)
{
return wsi->protocol;
}
LWS_VISIBLE int
-libwebsocket_is_final_fragment(struct libwebsocket *wsi)
+lws_is_final_fragment(struct libwebsocket *wsi)
{
return wsi->u.ws.final;
}
LWS_VISIBLE unsigned char
-libwebsocket_get_reserved_bits(struct libwebsocket *wsi)
+lws_get_reserved_bits(struct libwebsocket *wsi)
{
return wsi->u.ws.rsv;
}
@@ -884,12 +884,12 @@ lws_is_ssl(struct libwebsocket *wsi)
* lws_partial_buffered() - find out if lws buffered the last write
* @wsi: websocket connection to check
*
- * Returns 1 if you cannot use libwebsocket_write because the last
+ * Returns 1 if you cannot use lws_write because the last
* write on this connection is still buffered, and can't be cleared without
* returning to the service loop and waiting for the connection to be
* writeable again.
*
- * If you will try to do >1 libwebsocket_write call inside a single
+ * If you will try to do >1 lws_write call inside a single
* WRITEABLE callback, you must check this after every write and bail if
* set, ask for a new writeable callback and continue writing from there.
*
@@ -912,8 +912,8 @@ void lws_set_protocol_write_pending(struct libwebsocket_context *context,
if (wsi->pps)
lwsl_err("pps overwrite\n");
wsi->pps = pend;
- libwebsocket_rx_flow_control(wsi, 0);
- libwebsocket_callback_on_writable(context, wsi);
+ lws_rx_flow_control(wsi, 0);
+ lws_callback_on_writable(context, wsi);
}
LWS_VISIBLE size_t
diff --git a/lib/libwebsockets.h b/lib/libwebsockets.h
index 54bcfb3c..812bcd38 100644
--- a/lib/libwebsockets.h
+++ b/lib/libwebsockets.h
@@ -56,7 +56,7 @@
#define libwebsockets_SHA1 lws_SHA1
#define libwebsocket_read lws_read
#define libwebsocket_get_internal_extensions lws_get_internal_extensions
-
+#define libwebsocket_write_protocol lws_write_protocol
#ifdef __cplusplus
#include
@@ -421,7 +421,7 @@ enum libwebsocket_extension_callback_reasons {
LWS_EXT_CALLBACK_PAYLOAD_RX,
};
-enum libwebsocket_write_protocol {
+enum lws_write_protocol {
LWS_WRITE_TEXT,
LWS_WRITE_BINARY,
LWS_WRITE_CONTINUATION,
@@ -779,7 +779,7 @@ struct libwebsocket_extension;
* for example, to send a script to the client
* which will then open the websockets connection.
* @in points to the URI path requested and
- * libwebsockets_serve_http_file() makes it very
+ * lws_serve_http_file() makes it very
* simple to send back a file to the client.
* Normally after sending the file you are done
* with the http connection, since the rest of the
@@ -804,7 +804,7 @@ struct libwebsocket_extension;
*
* LWS_CALLBACK_CLIENT_WRITEABLE:
* LWS_CALLBACK_SERVER_WRITEABLE: If you call
- * libwebsocket_callback_on_writable() on a connection, you will
+ * lws_callback_on_writable() on a connection, you will
* get one of these callbacks coming when the connection socket
* is able to accept another write packet without blocking.
* If it already was able to take another packet without blocking,
@@ -1101,7 +1101,7 @@ typedef int (extension_callback_function)(struct libwebsocket_context *context,
* you support. If the frame size is exceeded, there is no
* error, but the buffer will spill to the user callback when
* full, which you can detect by using
- * libwebsockets_remaining_packet_payload(). Notice that you
+ * lws_remaining_packet_payload(). Notice that you
* just talk about frame size here, the LWS_SEND_BUFFER_PRE_PADDING
* and post-padding are automatically also allocated on top.
* @id: ignored by lws, but useful to contain user information bound
@@ -1111,7 +1111,7 @@ typedef int (extension_callback_function)(struct libwebsocket_context *context,
* switch (wsi->protocol->id), user code might use some bits as
* capability flags based on selected protocol version, etc.
* @user: User provided context data at the protocol level.
- * Accessible via libwebsockets_get_protocol(wsi)->user
+ * Accessible via lws_get_protocol(wsi)->user
* This should not be confused with wsi->user, it is not the same.
* The library completely ignores any value in here.
* @owning_server: the server init call fills in this opaque pointer when
@@ -1203,7 +1203,7 @@ struct libwebsocket_extension {
* @uid: user id to change to after setting listen socket, or -1.
* @options: 0, or LWS_SERVER_OPTION_DEFEAT_CLIENT_MASK
* @user: optional user pointer that can be recovered via the context
- * pointer using libwebsocket_context_user
+ * pointer using lws_context_user
* @ka_time: 0 for no keepalive, otherwise apply this keepalive timeout to
* all libwebsocket sockets, client or server
* @ka_probes: if ka_time was nonzero, after the timeout expires how many
@@ -1360,7 +1360,7 @@ lws_set_timeout(struct libwebsocket *wsi,
* This allows us to add protocol info before and after the data, and send as
* one packet on the network without payload copying, for maximum efficiency.
*
- * So for example you need this kind of code to use libwebsocket_write with a
+ * So for example you need this kind of code to use lws_write with a
* 128-byte payload
*
* char buf[LWS_SEND_BUFFER_PRE_PADDING + 128 + LWS_SEND_BUFFER_POST_PADDING];
@@ -1368,7 +1368,7 @@ lws_set_timeout(struct libwebsocket *wsi,
* // fill your part of the buffer... for example here it's all zeros
* memset(&buf[LWS_SEND_BUFFER_PRE_PADDING], 0, 128);
*
- * libwebsocket_write(wsi, &buf[LWS_SEND_BUFFER_PRE_PADDING], 128,
+ * lws_write(wsi, &buf[LWS_SEND_BUFFER_PRE_PADDING], 128,
* LWS_WRITE_TEXT);
*
* When sending LWS_WRITE_HTTP, there is no protocol addition and you can just
@@ -1409,7 +1409,7 @@ lws_set_timeout(struct libwebsocket *wsi,
LWS_VISIBLE LWS_EXTERN int
lws_write(struct libwebsocket *wsi, unsigned char *buf, size_t len,
- enum libwebsocket_write_protocol protocol);
+ enum lws_write_protocol protocol);
/* helper for case where buffer may be const */
#define lws_write_http(wsi, buf, len) \
diff --git a/lib/lws-plat-mbed3.c b/lib/lws-plat-mbed3.c
index d11bfeed..de5956f6 100644
--- a/lib/lws-plat-mbed3.c
+++ b/lib/lws-plat-mbed3.c
@@ -12,7 +12,7 @@ unsigned long long time_in_microseconds(void)
return 0;
}
-LWS_VISIBLE int libwebsockets_get_random(struct libwebsocket_context *context,
+LWS_VISIBLE int lws_get_random(struct libwebsocket_context *context,
void *buf, int len)
{
(void)context;
@@ -71,17 +71,17 @@ lws_poll_listen_fd(struct libwebsocket_pollfd *fd)
}
/**
- * libwebsocket_cancel_service() - Cancel servicing of pending websocket activity
+ * lws_cancel_service() - Cancel servicing of pending websocket activity
* @context: Websocket context
*
- * This function let a call to libwebsocket_service() waiting for a timeout
+ * This function let a call to lws_service() waiting for a timeout
* immediately return.
*
* There is no poll() in MBED3, he will fire callbacks when he feels like
* it.
*/
LWS_VISIBLE void
-libwebsocket_cancel_service(struct libwebsocket_context *context)
+lws_cancel_service(struct libwebsocket_context *context)
{
(void)context;
}
diff --git a/lib/lws-plat-mbed3.cpp b/lib/lws-plat-mbed3.cpp
index ca0a1a33..e0f5b935 100644
--- a/lib/lws-plat-mbed3.cpp
+++ b/lib/lws-plat-mbed3.cpp
@@ -35,7 +35,7 @@ void lws_conn::serialized_writeable(struct libwebsocket *_wsi)
lwsl_debug("%s: wsi %p\r\n", __func__, (void *)wsi);
- libwebsocket_service_fd(wsi->protocol->owning_server, &pollfd);
+ lws_service_fd(wsi->protocol->owning_server, &pollfd);
}
extern "C" void mbed3_tcp_stream_bind(void *sock, int port, struct libwebsocket *wsi)
@@ -169,7 +169,7 @@ int lws_conn::actual_onRX(Socket *s)
lwsl_debug("%s: lws %p\n", __func__, wsi);
- return libwebsocket_service_fd(wsi->protocol->owning_server, &pollfd);
+ return lws_service_fd(wsi->protocol->owning_server, &pollfd);
}
/*
@@ -285,7 +285,7 @@ void lws_conn::onSent(Socket *s, uint16_t len)
lwsl_debug("%s: wsi %p (servicing now)\r\n", __func__, (void *)wsi);
- libwebsocket_service_fd(wsi->protocol->owning_server, &pollfd);
+ lws_service_fd(wsi->protocol->owning_server, &pollfd);
}
void lws_conn_listener::onError(Socket *s, socket_error_t err)
diff --git a/lib/lws-plat-unix.c b/lib/lws-plat-unix.c
index bc133809..720e3d09 100644
--- a/lib/lws-plat-unix.c
+++ b/lib/lws-plat-unix.c
@@ -14,7 +14,7 @@ unsigned long long time_in_microseconds(void)
return ((unsigned long long)tv.tv_sec * 1000000LL) + tv.tv_usec;
}
-LWS_VISIBLE int libwebsockets_get_random(struct libwebsocket_context *context,
+LWS_VISIBLE int lws_get_random(struct libwebsocket_context *context,
void *buf, int len)
{
return read(context->fd_random, (char *)buf, len);
@@ -58,14 +58,14 @@ static void lws_sigusr2(int sig)
}
/**
- * libwebsocket_cancel_service() - Cancel servicing of pending websocket activity
+ * lws_cancel_service() - Cancel servicing of pending websocket activity
* @context: Websocket context
*
- * This function let a call to libwebsocket_service() waiting for a timeout
+ * This function let a call to lws_service() waiting for a timeout
* immediately return.
*/
LWS_VISIBLE void
-libwebsocket_cancel_service(struct libwebsocket_context *context)
+lws_cancel_service(struct libwebsocket_context *context)
{
char buf = 0;
@@ -127,7 +127,7 @@ lws_plat_service(struct libwebsocket_context *context, int timeout_ms)
#else
if (n == 0) /* poll timeout */ {
#endif
- libwebsocket_service_fd(context, NULL);
+ lws_service_fd(context, NULL);
return 0;
}
@@ -176,7 +176,7 @@ lws_plat_service(struct libwebsocket_context *context, int timeout_ms)
continue;
}
- m = libwebsocket_service_fd(context, &context->fds[n]);
+ m = lws_service_fd(context, &context->fds[n]);
if (m < 0)
return -1;
/* if something closed, retry this slot */
diff --git a/lib/lws-plat-win.c b/lib/lws-plat-win.c
index 01e8a058..0610beb9 100644
--- a/lib/lws-plat-win.c
+++ b/lib/lws-plat-win.c
@@ -86,7 +86,7 @@ delete_from_fd(struct libwebsocket_context *context, int fd)
return 1;
}
-LWS_VISIBLE int libwebsockets_get_random(struct libwebsocket_context *context,
+LWS_VISIBLE int lws_get_random(struct libwebsocket_context *context,
void *buf, int len)
{
int n;
@@ -117,14 +117,14 @@ LWS_VISIBLE int lws_poll_listen_fd(struct libwebsocket_pollfd *fd)
}
/**
- * libwebsocket_cancel_service() - Cancel servicing of pending websocket activity
+ * lws_cancel_service() - Cancel servicing of pending websocket activity
* @context: Websocket context
*
- * This function let a call to libwebsocket_service() waiting for a timeout
+ * This function let a call to lws_service() waiting for a timeout
* immediately return.
*/
LWS_VISIBLE void
-libwebsocket_cancel_service(struct libwebsocket_context *context)
+lws_cancel_service(struct libwebsocket_context *context)
{
WSASetEvent(context->events[0]);
}
@@ -162,7 +162,7 @@ lws_plat_service(struct libwebsocket_context *context, int timeout_ms)
if (!wsi || wsi->sock_send_blocking)
continue;
pfd->revents = LWS_POLLOUT;
- n = libwebsocket_service_fd(context, pfd);
+ n = lws_service_fd(context, pfd);
if (n < 0)
return n;
}
@@ -173,7 +173,7 @@ lws_plat_service(struct libwebsocket_context *context, int timeout_ms)
context->service_tid = 0;
if (ev == WSA_WAIT_TIMEOUT) {
- libwebsocket_service_fd(context, NULL);
+ lws_service_fd(context, NULL);
return 0;
}
@@ -203,7 +203,7 @@ lws_plat_service(struct libwebsocket_context *context, int timeout_ms)
wsi->sock_send_blocking = FALSE;
}
- return libwebsocket_service_fd(context, pfd);
+ return lws_service_fd(context, pfd);
}
LWS_VISIBLE int
diff --git a/lib/output.c b/lib/output.c
index 6a595c9c..16fd1e9d 100644
--- a/lib/output.c
+++ b/lib/output.c
@@ -28,7 +28,7 @@ libwebsocket_0405_frame_mask_generate(struct libwebsocket *wsi)
/* fetch the per-frame nonce */
- n = libwebsockets_get_random(wsi->protocol->owning_server,
+ n = lws_get_random(wsi->protocol->owning_server,
wsi->u.ws.frame_masking_nonce_04, 4);
if (n != 4) {
lwsl_parser("Unable to read from random device %s %d\n",
@@ -162,7 +162,7 @@ handle_truncated_send:
}
}
/* always callback on writeable */
- libwebsocket_callback_on_writable(
+ lws_callback_on_writable(
wsi->protocol->owning_server, wsi);
return n;
@@ -211,13 +211,13 @@ handle_truncated_send:
memcpy(wsi->truncated_send_malloc, buf + n, real_len - n);
/* since something buffered, force it to get another chance to send */
- libwebsocket_callback_on_writable(wsi->protocol->owning_server, wsi);
+ lws_callback_on_writable(wsi->protocol->owning_server, wsi);
return real_len;
}
/**
- * libwebsocket_write() - Apply protocol then write data to client
+ * lws_write() - Apply protocol then write data to client
* @wsi: Websocket instance (available from user callback)
* @buf: The data to send. For data being sent on a websocket
* connection (ie, not default http), this buffer MUST have
@@ -246,8 +246,8 @@ handle_truncated_send:
* pressure at any given time.
*/
-LWS_VISIBLE int libwebsocket_write(struct libwebsocket *wsi, unsigned char *buf,
- size_t len, enum libwebsocket_write_protocol protocol)
+LWS_VISIBLE int lws_write(struct libwebsocket *wsi, unsigned char *buf,
+ size_t len, enum lws_write_protocol protocol)
{
int n;
int pre = 0;
@@ -260,7 +260,7 @@ LWS_VISIBLE int libwebsocket_write(struct libwebsocket *wsi, unsigned char *buf,
if (len == 0 && protocol != LWS_WRITE_CLOSE &&
protocol != LWS_WRITE_PING && protocol != LWS_WRITE_PONG) {
- lwsl_warn("zero length libwebsocket_write attempt\n");
+ lwsl_warn("zero length lws_write attempt\n");
return 0;
}
@@ -508,14 +508,14 @@ send_raw:
/*
* it is how many bytes of user buffer got sent... may be < orig_len
* in which case callback when writable has already been arranged
- * and user code can call libwebsocket_write() again with the rest
+ * and user code can call lws_write() again with the rest
* later.
*/
return n - (pre + post);
}
-LWS_VISIBLE int libwebsockets_serve_http_file_fragment(
+LWS_VISIBLE int lws_serve_http_file_fragment(
struct libwebsocket_context *context, struct libwebsocket *wsi)
{
int n;
@@ -527,7 +527,7 @@ LWS_VISIBLE int libwebsockets_serve_http_file_fragment(
if (lws_issue_raw(wsi, wsi->truncated_send_malloc +
wsi->truncated_send_offset,
wsi->truncated_send_len) < 0) {
- lwsl_info("closing from libwebsockets_serve_http_file_fragment\n");
+ lwsl_info("closing from lws_serve_http_file_fragment\n");
return -1;
}
continue;
@@ -541,9 +541,9 @@ LWS_VISIBLE int libwebsockets_serve_http_file_fragment(
if (n < 0)
return -1; /* caller will close */
if (n) {
- libwebsocket_set_timeout(wsi, PENDING_TIMEOUT_HTTP_CONTENT, AWAITING_TIMEOUT);
+ lws_set_timeout(wsi, PENDING_TIMEOUT_HTTP_CONTENT, AWAITING_TIMEOUT);
wsi->u.http.filepos += n;
- m = libwebsocket_write(wsi, context->service_buffer, n,
+ m = lws_write(wsi, context->service_buffer, n,
wsi->u.http.filepos == wsi->u.http.filelen ? LWS_WRITE_HTTP_FINAL : LWS_WRITE_HTTP);
if (m < 0)
return -1;
@@ -573,7 +573,7 @@ all_sent:
}
lwsl_info("choked before able to send whole file (post)\n");
- libwebsocket_callback_on_writable(context, wsi);
+ lws_callback_on_writable(context, wsi);
return 0; /* indicates further processing must be done */
}
diff --git a/lib/parsers.c b/lib/parsers.c
index cec9585c..83124ffe 100644
--- a/lib/parsers.c
+++ b/lib/parsers.c
@@ -929,7 +929,7 @@ process_as_ping:
wsi->u.ws.ping_pending_flag = 1;
/* get it sent as soon as possible */
- libwebsocket_callback_on_writable(wsi->protocol->owning_server, wsi);
+ lws_callback_on_writable(wsi->protocol->owning_server, wsi);
ping_drop:
wsi->u.ws.rx_user_buffer_head = 0;
return 0;
@@ -974,7 +974,7 @@ ping_drop:
/*
* No it's real payload, pass it up to the user callback.
* It's nicely buffered with the pre-padding taken care of
- * so it can be sent straight out again using libwebsocket_write
+ * so it can be sent straight out again using lws_write
*/
eff_buf.token = &wsi->u.ws.rx_user_buffer[
@@ -1022,7 +1022,7 @@ illegal_ctl_length:
/**
- * libwebsockets_remaining_packet_payload() - Bytes to come before "overall"
+ * lws_remaining_packet_payload() - Bytes to come before "overall"
* rx packet is complete
* @wsi: Websocket instance (available from user callback)
*
@@ -1032,14 +1032,14 @@ illegal_ctl_length:
* additionally when it hits a built-in limit. The LWS_CALLBACK_RECEIVE
* callback handler can use this API to find out if the buffer it has just
* been given is the last piece of a "complete packet" from the client --
- * when that is the case libwebsockets_remaining_packet_payload() will return
+ * when that is the case lws_remaining_packet_payload() will return
* 0.
*
* Many protocols won't care becuse their packets are always small.
*/
LWS_VISIBLE size_t
-libwebsockets_remaining_packet_payload(struct libwebsocket *wsi)
+lws_remaining_packet_payload(struct libwebsocket *wsi)
{
return wsi->u.ws.rx_packet_length;
}
diff --git a/lib/pollfd.c b/lib/pollfd.c
index bdf0172a..83e1c9d2 100644
--- a/lib/pollfd.c
+++ b/lib/pollfd.c
@@ -184,7 +184,7 @@ lws_change_pollfd(struct libwebsocket *wsi, int _and, int _or)
if (tid == -1)
return -1;
if (tid != sampled_tid)
- libwebsocket_cancel_service(context);
+ lws_cancel_service(context);
}
}
@@ -197,7 +197,7 @@ lws_change_pollfd(struct libwebsocket *wsi, int _and, int _or)
/**
- * libwebsocket_callback_on_writable() - Request a callback when this socket
+ * lws_callback_on_writable() - Request a callback when this socket
* becomes able to be written to without
* blocking
*
@@ -206,7 +206,7 @@ lws_change_pollfd(struct libwebsocket *wsi, int _and, int _or)
*/
LWS_VISIBLE int
-libwebsocket_callback_on_writable(struct libwebsocket_context *context,
+lws_callback_on_writable(struct libwebsocket_context *context,
struct libwebsocket *wsi)
{
#ifdef LWS_USE_HTTP2
@@ -275,7 +275,7 @@ network_sock:
}
/**
- * libwebsocket_callback_on_writable_all_protocol() - Request a callback for
+ * lws_callback_on_writable_all_protocol() - Request a callback for
* all connections using the given protocol when it
* becomes possible to write to each socket without
* blocking in turn.
@@ -284,7 +284,7 @@ network_sock:
*/
LWS_VISIBLE int
-libwebsocket_callback_on_writable_all_protocol(
+lws_callback_on_writable_all_protocol(
const struct libwebsocket_protocols *protocol)
{
struct libwebsocket_context *context = protocol->owning_server;
@@ -296,7 +296,7 @@ libwebsocket_callback_on_writable_all_protocol(
if (!wsi)
continue;
if (wsi->protocol == protocol)
- libwebsocket_callback_on_writable(context, wsi);
+ lws_callback_on_writable(context, wsi);
}
return 0;
diff --git a/lib/private-libwebsockets.h b/lib/private-libwebsockets.h
index 50ed0f14..b24354fa 100644
--- a/lib/private-libwebsockets.h
+++ b/lib/private-libwebsockets.h
@@ -867,7 +867,7 @@ struct libwebsocket {
char mode; /* enum connection_mode */
char state; /* enum lws_connection_states */
char lws_rx_parse_state; /* enum lws_rx_parse_state */
- char rx_frame_type; /* enum libwebsocket_write_protocol */
+ char rx_frame_type; /* enum lws_write_protocol */
unsigned int hdr_parsing_completed:1;
unsigned int user_space_externally_allocated:1;
@@ -985,11 +985,11 @@ lws_issue_raw(struct libwebsocket *wsi, unsigned char *buf, size_t len);
LWS_EXTERN int
-libwebsocket_service_timeout_check(struct libwebsocket_context *context,
+lws_service_timeout_check(struct libwebsocket_context *context,
struct libwebsocket *wsi, unsigned int sec);
LWS_EXTERN struct libwebsocket *
-libwebsocket_client_connect_2(struct libwebsocket_context *context,
+lws_client_connect_2(struct libwebsocket_context *context,
struct libwebsocket *wsi);
LWS_EXTERN struct libwebsocket *
@@ -1044,7 +1044,7 @@ lws_issue_raw_ext_access(struct libwebsocket *wsi,
unsigned char *buf, size_t len);
LWS_EXTERN int
-_libwebsocket_rx_flow_control(struct libwebsocket *wsi);
+_lws_rx_flow_control(struct libwebsocket *wsi);
LWS_EXTERN void
lws_union_transition(struct libwebsocket *wsi, enum connection_mode mode);
@@ -1245,12 +1245,12 @@ lws_ssl_pending_no_ssl(struct libwebsocket *wsi);
LWS_EXTERN int lws_server_socket_service(
struct libwebsocket_context *context,
struct libwebsocket *wsi, struct libwebsocket_pollfd *pollfd);
- LWS_EXTERN int _libwebsocket_rx_flow_control(struct libwebsocket *wsi);
+ 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);
#else
#define lws_server_socket_service(_a, _b, _c) (0)
-#define _libwebsocket_rx_flow_control(_a) (0)
+#define _lws_rx_flow_control(_a) (0)
#define lws_handshake_server(_a, _b, _c, _d) (0)
#endif
diff --git a/lib/server-handshake.c b/lib/server-handshake.c
index 298fae43..2e2cf5cd 100644
--- a/lib/server-handshake.c
+++ b/lib/server-handshake.c
@@ -185,7 +185,7 @@ handshake_0405(struct libwebsocket_context *context, struct libwebsocket *wsi)
"%s258EAFA5-E914-47DA-95CA-C5AB0DC85B11",
lws_hdr_simple_ptr(wsi, WSI_TOKEN_KEY));
- libwebsockets_SHA1(context->service_buffer, n, hash);
+ lws_SHA1(context->service_buffer, n, hash);
accept_len = lws_b64_encode_string((char *)hash, 20,
(char *)context->service_buffer,
@@ -245,7 +245,7 @@ handshake_0405(struct libwebsocket_context *context, struct libwebsocket *wsi)
#ifdef DEBUG
fwrite(response, 1, p - response, stderr);
#endif
- n = libwebsocket_write(wsi, (unsigned char *)response,
+ n = lws_write(wsi, (unsigned char *)response,
p - response, LWS_WRITE_HTTP_HEADERS);
if (n != (p - response)) {
lwsl_debug("handshake_0405: ERROR writing to socket\n");
diff --git a/lib/server.c b/lib/server.c
index 4256d3c5..7522ef52 100644
--- a/lib/server.c
+++ b/lib/server.c
@@ -151,7 +151,7 @@ int lws_context_init_server(struct lws_context_creation_info *info,
}
int
-_libwebsocket_rx_flow_control(struct libwebsocket *wsi)
+_lws_rx_flow_control(struct libwebsocket *wsi)
{
struct libwebsocket_context *context = wsi->protocol->owning_server;
@@ -162,7 +162,7 @@ _libwebsocket_rx_flow_control(struct libwebsocket *wsi)
/* stuff is still buffered, not ready to really accept new input */
if (wsi->rxflow_buffer) {
/* get ourselves called back to deal with stashed buffer */
- libwebsocket_callback_on_writable(context, wsi);
+ lws_callback_on_writable(context, wsi);
return 0;
}
@@ -304,7 +304,7 @@ int lws_http_action(struct libwebsocket_context *context,
* if there is content supposed to be coming,
* put a timeout on it having arrived
*/
- libwebsocket_set_timeout(wsi, PENDING_TIMEOUT_HTTP_CONTENT,
+ lws_set_timeout(wsi, PENDING_TIMEOUT_HTTP_CONTENT,
AWAITING_TIMEOUT);
if (wsi->protocol->callback)
@@ -325,7 +325,7 @@ int lws_http_action(struct libwebsocket_context *context,
* HTTP keep-alive. No keep-alive header allocation for
* ISSUING_FILE, as this uses HTTP/1.0.
*
- * In any case, return 0 and let libwebsocket_read decide how to
+ * In any case, return 0 and let lws_read decide how to
* proceed based on state
*/
if (wsi->state != WSI_STATE_HTTP_ISSUING_FILE)
@@ -367,7 +367,7 @@ int lws_handshake_server(struct libwebsocket_context *context,
lwsl_parser("libwebsocket_parse sees parsing complete\n");
wsi->mode = LWS_CONNMODE_PRE_WS_SERVING_ACCEPT;
- libwebsocket_set_timeout(wsi, NO_PENDING_TIMEOUT, 0);
+ lws_set_timeout(wsi, NO_PENDING_TIMEOUT, 0);
/* is this websocket protocol or normal http 1.0? */
@@ -450,7 +450,7 @@ upgrade_h2c:
upgrade_ws:
if (!wsi->protocol)
- lwsl_err("NULL protocol at libwebsocket_read\n");
+ lwsl_err("NULL protocol at lws_read\n");
/*
* It's websocket
@@ -670,7 +670,7 @@ int lws_http_transaction_completed(struct libwebsocket *wsi)
wsi->u.http.content_length = 0;
/* He asked for it to stay alive indefinitely */
- libwebsocket_set_timeout(wsi, NO_PENDING_TIMEOUT, 0);
+ lws_set_timeout(wsi, NO_PENDING_TIMEOUT, 0);
if (lws_allocate_header_table(wsi))
return 1;
@@ -749,7 +749,7 @@ int lws_server_socket_service(struct libwebsocket_context *context,
if (wsi->state != WSI_STATE_FLUSHING_STORED_SEND_BEFORE_CLOSE) {
/* hm this may want to send (via HTTP callback for example) */
- n = libwebsocket_read(context, wsi,
+ n = lws_read(context, wsi,
context->service_buffer, len);
if (n < 0)
/* we closed wsi */
@@ -786,7 +786,7 @@ try_pollout:
}
/* >0 == completion, <0 == error */
- n = libwebsockets_serve_http_file_fragment(context, wsi);
+ n = lws_serve_http_file_fragment(context, wsi);
if (n < 0 || (n > 0 && lws_http_transaction_completed(wsi)))
goto fail;
break;
@@ -845,7 +845,7 @@ try_pollout:
new_wsi->sock = accept_fd;
/* the transport is accepted... give him time to negotiate */
- libwebsocket_set_timeout(new_wsi,
+ lws_set_timeout(new_wsi,
PENDING_TIMEOUT_ESTABLISH_WITH_SERVER,
AWAITING_TIMEOUT);
@@ -891,7 +891,7 @@ fail:
}
/**
- * libwebsockets_serve_http_file() - Send a file back to the client using http
+ * lws_serve_http_file() - Send a file back to the client using http
* @context: libwebsockets context
* @wsi: Websocket instance (available from user callback)
* @file: The file to issue over http
@@ -909,7 +909,7 @@ fail:
* the wsi should be left alone.
*/
-LWS_VISIBLE int libwebsockets_serve_http_file(
+LWS_VISIBLE int lws_serve_http_file(
struct libwebsocket_context *context,
struct libwebsocket *wsi, const char *file,
const char *content_type, const char *other_headers,
@@ -925,7 +925,7 @@ LWS_VISIBLE int libwebsockets_serve_http_file(
if (wsi->u.http.fd == LWS_INVALID_FILE) {
lwsl_err("Unable to open '%s'\n", file);
- libwebsockets_return_http_status(context, wsi,
+ lws_return_http_status(context, wsi,
HTTP_STATUS_NOT_FOUND, NULL);
return -1;
}
@@ -949,7 +949,7 @@ LWS_VISIBLE int libwebsockets_serve_http_file(
if (lws_finalize_http_header(context, wsi, &p, end))
return -1;
- ret = libwebsocket_write(wsi, response,
+ ret = lws_write(wsi, response,
p - response, LWS_WRITE_HTTP_HEADERS);
if (ret != (p - response)) {
lwsl_err("_write returned %d from %d\n", ret, (p - response));
@@ -959,7 +959,7 @@ LWS_VISIBLE int libwebsockets_serve_http_file(
wsi->u.http.filepos = 0;
wsi->state = WSI_STATE_HTTP_ISSUING_FILE;
- return libwebsockets_serve_http_file_fragment(context, wsi);
+ return lws_serve_http_file_fragment(context, wsi);
}
diff --git a/lib/service.c b/lib/service.c
index 283c3923..cc230d0c 100644
--- a/lib/service.c
+++ b/lib/service.c
@@ -86,7 +86,7 @@ lws_handle_POLLOUT_event(struct libwebsocket_context *context,
break;
}
wsi->pps = LWS_PPS_NONE;
- libwebsocket_rx_flow_control(wsi, 1);
+ lws_rx_flow_control(wsi, 1);
return 0; /* leave POLLOUT active */
}
@@ -101,7 +101,7 @@ lws_handle_POLLOUT_event(struct libwebsocket_context *context,
if (wsi->u.ws.payload_is_close)
write_type = LWS_WRITE_CLOSE;
- n = libwebsocket_write(wsi,
+ n = lws_write(wsi,
&wsi->u.ws.ping_payload_buf[
LWS_SEND_BUFFER_PRE_PADDING],
wsi->u.ws.ping_payload_len,
@@ -280,7 +280,7 @@ notify:
int
-libwebsocket_service_timeout_check(struct libwebsocket_context *context,
+lws_service_timeout_check(struct libwebsocket_context *context,
struct libwebsocket *wsi, unsigned int sec)
{
/*
@@ -335,7 +335,7 @@ int lws_rxflow_cache(struct libwebsocket *wsi, unsigned char *buf, int n, int le
}
/**
- * libwebsocket_service_fd() - Service polled socket with something waiting
+ * lws_service_fd() - Service polled socket with something waiting
* @context: Websocket context
* @pollfd: The pollfd entry describing the socket fd and which events
* happened.
@@ -358,7 +358,7 @@ int lws_rxflow_cache(struct libwebsocket *wsi, unsigned char *buf, int n, int le
*/
LWS_VISIBLE int
-libwebsocket_service_fd(struct libwebsocket_context *context,
+lws_service_fd(struct libwebsocket_context *context,
struct libwebsocket_pollfd *pollfd)
{
struct libwebsocket *wsi;
@@ -404,7 +404,7 @@ libwebsocket_service_fd(struct libwebsocket_context *context,
if (!wsi)
continue;
- if (libwebsocket_service_timeout_check(context, wsi, now))
+ if (lws_service_timeout_check(context, wsi, now))
/* he did time out... */
if (mfd == our_fd) {
/* it was the guy we came to service! */
@@ -460,7 +460,7 @@ libwebsocket_service_fd(struct libwebsocket_context *context,
*/
n = lws_poll_listen_fd(&context->fds[listen_socket_fds_index]);
if (n > 0) { /* there's a conn waiting for us */
- libwebsocket_service_fd(context,
+ lws_service_fd(context,
&context->
fds[listen_socket_fds_index]);
context->listen_service_extraseen++;
@@ -517,7 +517,7 @@ libwebsocket_service_fd(struct libwebsocket_context *context,
lws_handle_POLLOUT_event(context, wsi, pollfd)) {
if (wsi->state == WSI_STATE_RETURNED_CLOSE_ALREADY)
wsi->state = WSI_STATE_FLUSHING_STORED_SEND_BEFORE_CLOSE;
- lwsl_info("libwebsocket_service_fd: closing\n");
+ lwsl_info("lws_service_fd: closing\n");
goto close_and_handled;
}
@@ -583,7 +583,7 @@ drain:
/* service incoming data */
if (eff_buf.token_len) {
- n = libwebsocket_read(context, wsi,
+ n = lws_read(context, wsi,
(unsigned char *)eff_buf.token,
eff_buf.token_len);
if (n < 0) {
@@ -613,7 +613,7 @@ handle_pending:
#ifdef LWS_NO_SERVER
n =
#endif
- _libwebsocket_rx_flow_control(wsi); /* n ignored, needed for NO_SERVER case */
+ _lws_rx_flow_control(wsi); /* n ignored, needed for NO_SERVER case */
}
break;
@@ -643,7 +643,7 @@ handled:
}
/**
- * libwebsocket_service() - Service any pending websocket activity
+ * lws_service() - Service any pending websocket activity
* @context: Websocket context
* @timeout_ms: Timeout for poll; 0 means return immediately if nothing needed
* service otherwise block and service immediately, returning
@@ -675,7 +675,7 @@ handled:
*/
LWS_VISIBLE int
-libwebsocket_service(struct libwebsocket_context *context, int timeout_ms)
+lws_service(struct libwebsocket_context *context, int timeout_ms)
{
return lws_plat_service(context, timeout_ms);
}
diff --git a/lib/sha-1.c b/lib/sha-1.c
index 019f92a1..3dd9d3fa 100644
--- a/lib/sha-1.c
+++ b/lib/sha-1.c
@@ -287,7 +287,7 @@ sha1_result(struct sha1_ctxt *ctxt, void *digest0)
*/
LWS_VISIBLE unsigned char *
-libwebsockets_SHA1(const unsigned char *d, size_t n, unsigned char *md)
+lws_SHA1(const unsigned char *d, size_t n, unsigned char *md)
{
struct sha1_ctxt ctx;
diff --git a/lib/ssl.c b/lib/ssl.c
index ad56ebee..9a51cd80 100644
--- a/lib/ssl.c
+++ b/lib/ssl.c
@@ -594,7 +594,7 @@ lws_server_socket_service_ssl(struct libwebsocket_context *context,
if (insert_wsi_socket_into_fds(context, wsi))
goto fail;
- libwebsocket_set_timeout(wsi, PENDING_TIMEOUT_SSL_ACCEPT,
+ lws_set_timeout(wsi, PENDING_TIMEOUT_SSL_ACCEPT,
AWAITING_TIMEOUT);
lwsl_info("inserted SSL accept into fds, trying SSL_accept\n");
@@ -692,7 +692,7 @@ go_again:
accepted:
/* OK, we are accepted... give him some time to negotiate */
- libwebsocket_set_timeout(wsi,
+ lws_set_timeout(wsi,
PENDING_TIMEOUT_ESTABLISH_WITH_SERVER,
AWAITING_TIMEOUT);
diff --git a/test-server/test-client.c b/test-server/test-client.c
index 5d3b6804..ec9fbac4 100644
--- a/test-server/test-client.c
+++ b/test-server/test-client.c
@@ -141,7 +141,7 @@ callback_lws_mirror(struct libwebsocket_context *context,
fprintf(stderr, "callback_lws_mirror: LWS_CALLBACK_CLIENT_ESTABLISHED\n");
- libwebsockets_get_random(context, rands, sizeof(rands[0]));
+ lws_get_random(context, rands, sizeof(rands[0]));
mirror_lifetime = 10 + (rands[0] & 1023);
/* useful to test single connection stability */
if (longlived)
@@ -162,7 +162,7 @@ callback_lws_mirror(struct libwebsocket_context *context,
* LWS_CALLBACK_CLIENT_WRITEABLE will come next service
*/
- libwebsocket_callback_on_writable(context, wsi);
+ lws_callback_on_writable(context, wsi);
break;
case LWS_CALLBACK_CLOSED:
@@ -177,7 +177,7 @@ callback_lws_mirror(struct libwebsocket_context *context,
case LWS_CALLBACK_CLIENT_WRITEABLE:
for (n = 0; n < 1; n++) {
- libwebsockets_get_random(context, rands, sizeof(rands));
+ lws_get_random(context, rands, sizeof(rands));
l += sprintf((char *)&buf[LWS_SEND_BUFFER_PRE_PADDING + l],
"c #%06X %d %d %d;",
(int)rands[0] & 0xffffff,
@@ -186,7 +186,7 @@ callback_lws_mirror(struct libwebsocket_context *context,
(int)rands[3] % 24);
}
- n = libwebsocket_write(wsi,
+ n = lws_write(wsi,
&buf[LWS_SEND_BUFFER_PRE_PADDING], l, opts | LWS_WRITE_TEXT);
if (n < 0)
@@ -202,7 +202,7 @@ callback_lws_mirror(struct libwebsocket_context *context,
return -1;
} else
/* get notified as soon as we can write again */
- libwebsocket_callback_on_writable(context, wsi);
+ lws_callback_on_writable(context, wsi);
break;
default:
@@ -319,12 +319,12 @@ int main(int argc, char **argv)
info.port = CONTEXT_PORT_NO_LISTEN;
info.protocols = protocols;
#ifndef LWS_NO_EXTENSIONS
- info.extensions = libwebsocket_get_internal_extensions();
+ info.extensions = lws_get_internal_extensions();
#endif
info.gid = -1;
info.uid = -1;
- context = libwebsocket_create_context(&info);
+ context = lws_create_context(&info);
if (context == NULL) {
fprintf(stderr, "Creating libwebsocket context failed\n");
return 1;
@@ -332,7 +332,7 @@ int main(int argc, char **argv)
/* create a client websocket using dumb increment protocol */
- wsi_dumb = libwebsocket_client_connect(context, address, port, use_ssl,
+ wsi_dumb = lws_client_connect(context, address, port, use_ssl,
"/", argv[optind], argv[optind],
protocols[PROTOCOL_DUMB_INCREMENT].name, ietf_version);
@@ -353,7 +353,7 @@ int main(int argc, char **argv)
n = 0;
while (n >= 0 && !was_closed && !force_exit) {
- n = libwebsocket_service(context, 10);
+ n = lws_service(context, 10);
if (n < 0)
continue;
@@ -363,7 +363,7 @@ int main(int argc, char **argv)
/* create a client websocket using mirror protocol */
- wsi_mirror = libwebsocket_client_connect(context,
+ wsi_mirror = lws_client_connect(context,
address, port, use_ssl, "/",
argv[optind], argv[optind],
protocols[PROTOCOL_LWS_MIRROR].name, ietf_version);
@@ -379,7 +379,7 @@ int main(int argc, char **argv)
bail:
fprintf(stderr, "Exiting\n");
- libwebsocket_context_destroy(context);
+ lws_context_destroy(context);
return ret;
diff --git a/test-server/test-echo.c b/test-server/test-echo.c
index f74a5c46..398fffb0 100644
--- a/test-server/test-echo.c
+++ b/test-server/test-echo.c
@@ -68,7 +68,7 @@ callback_echo(struct libwebsocket_context *context,
case LWS_CALLBACK_SERVER_WRITEABLE:
do_tx:
- n = libwebsocket_write(wsi, &pss->buf[LWS_SEND_BUFFER_PRE_PADDING], pss->len, LWS_WRITE_TEXT);
+ n = lws_write(wsi, &pss->buf[LWS_SEND_BUFFER_PRE_PADDING], pss->len, LWS_WRITE_TEXT);
if (n < 0) {
lwsl_err("ERROR %d writing to socket, hanging up\n", n);
return 1;
@@ -87,7 +87,7 @@ do_rx:
}
memcpy(&pss->buf[LWS_SEND_BUFFER_PRE_PADDING], in, len);
pss->len = (unsigned int)len;
- libwebsocket_callback_on_writable(context, wsi);
+ lws_callback_on_writable(context, wsi);
break;
#endif
@@ -122,7 +122,7 @@ do_rx:
/* we will send our packet... */
pss->len = sprintf((char *)&pss->buf[LWS_SEND_BUFFER_PRE_PADDING], "hello from libwebsockets-test-echo client pid %d index %d\n", getpid(), pss->index++);
lwsl_notice("Client TX: %s", &pss->buf[LWS_SEND_BUFFER_PRE_PADDING]);
- n = libwebsocket_write(wsi, &pss->buf[LWS_SEND_BUFFER_PRE_PADDING], pss->len, LWS_WRITE_TEXT);
+ n = lws_write(wsi, &pss->buf[LWS_SEND_BUFFER_PRE_PADDING], pss->len, LWS_WRITE_TEXT);
if (n < 0) {
lwsl_err("ERROR %d writing to socket, hanging up\n", n);
return -1;
@@ -364,7 +364,7 @@ int main(int argc, char **argv)
info.iface = _interface;
info.protocols = protocols;
#ifndef LWS_NO_EXTENSIONS
- info.extensions = libwebsocket_get_internal_extensions();
+ info.extensions = lws_get_internal_extensions();
#endif
if (use_ssl && !client) {
info.ssl_cert_filepath = ssl_cert;
@@ -378,7 +378,7 @@ int main(int argc, char **argv)
info.uid = -1;
info.options = opts;
- context = libwebsocket_create_context(&info);
+ context = lws_create_context(&info);
if (context == NULL) {
lwsl_err("libwebsocket init failed\n");
return -1;
@@ -403,7 +403,7 @@ int main(int argc, char **argv)
address[sizeof(address) - 1] = '\0';
sprintf(ads_port, "%s:%u", address, port & 65535);
- wsi = libwebsocket_client_connect(context, address,
+ wsi = lws_client_connect(context, address,
port, use_ssl, uri, ads_port,
ads_port, NULL, -1);
if (!wsi) {
@@ -416,17 +416,17 @@ int main(int argc, char **argv)
gettimeofday(&tv, NULL);
if (((((unsigned long long)tv.tv_sec * 1000000) + tv.tv_usec) - oldus) > rate_us) {
- libwebsocket_callback_on_writable_all_protocol(&protocols[0]);
+ lws_callback_on_writable_all_protocol(&protocols[0]);
oldus = ((unsigned long long)tv.tv_sec * 1000000) + tv.tv_usec;
}
}
#endif
- n = libwebsocket_service(context, 10);
+ n = lws_service(context, 10);
}
#ifndef LWS_NO_CLIENT
bail:
#endif
- libwebsocket_context_destroy(context);
+ lws_context_destroy(context);
lwsl_notice("libwebsockets-test-echo exited cleanly\n");
#ifndef _WIN32
diff --git a/test-server/test-fraggle.c b/test-server/test-fraggle.c
index 5faad257..c97d1098 100644
--- a/test-server/test-fraggle.c
+++ b/test-server/test-fraggle.c
@@ -76,7 +76,7 @@ callback_fraggle(struct libwebsocket_context *context,
fprintf(stderr, "server sees client connect\n");
psf->state = FRAGSTATE_START_MESSAGE;
/* start the ball rolling */
- libwebsocket_callback_on_writable(context, wsi);
+ lws_callback_on_writable(context, wsi);
break;
case LWS_CALLBACK_CLIENT_ESTABLISHED:
@@ -106,7 +106,7 @@ callback_fraggle(struct libwebsocket_context *context,
psf->total_message += len;
psf->packets_left++;
- if (libwebsocket_is_final_fragment(wsi))
+ if (lws_is_final_fragment(wsi))
psf->state = FRAGSTATE_POST_PAYLOAD_SUM;
break;
@@ -136,7 +136,7 @@ callback_fraggle(struct libwebsocket_context *context,
switch (psf->state) {
case FRAGSTATE_START_MESSAGE:
- libwebsockets_get_random(context, &ran, sizeof(ran));
+ lws_get_random(context, &ran, sizeof(ran));
psf->packets_left = (ran % 1024) + 1;
fprintf(stderr, "Spamming %d random fragments\n",
psf->packets_left);
@@ -155,11 +155,11 @@ callback_fraggle(struct libwebsocket_context *context,
* code for rx spill because the rx buffer is full
*/
- libwebsockets_get_random(context, &ran, sizeof(ran));
+ lws_get_random(context, &ran, sizeof(ran));
chunk = (ran % 8000) + 1;
psf->total_message += chunk;
- libwebsockets_get_random(context, bp, chunk);
+ lws_get_random(context, bp, chunk);
for (n = 0; n < chunk; n++)
psf->sum += bp[n];
@@ -169,7 +169,7 @@ callback_fraggle(struct libwebsocket_context *context,
else
psf->state = FRAGSTATE_POST_PAYLOAD_SUM;
- n = libwebsocket_write(wsi, bp, chunk, write_mode);
+ n = lws_write(wsi, bp, chunk, write_mode);
if (n < 0)
return -1;
if (n < chunk) {
@@ -177,7 +177,7 @@ callback_fraggle(struct libwebsocket_context *context,
return -1;
}
- libwebsocket_callback_on_writable(context, wsi);
+ lws_callback_on_writable(context, wsi);
break;
case FRAGSTATE_POST_PAYLOAD_SUM:
@@ -191,7 +191,7 @@ callback_fraggle(struct libwebsocket_context *context,
bp[2] = psf->sum >> 8;
bp[3] = psf->sum;
- n = libwebsocket_write(wsi, (unsigned char *)bp,
+ n = lws_write(wsi, (unsigned char *)bp,
4, LWS_WRITE_BINARY);
if (n < 0)
return -1;
@@ -202,7 +202,7 @@ callback_fraggle(struct libwebsocket_context *context,
psf->state = FRAGSTATE_START_MESSAGE;
- libwebsocket_callback_on_writable(context, wsi);
+ lws_callback_on_writable(context, wsi);
break;
}
break;
@@ -318,7 +318,7 @@ int main(int argc, char **argv)
info.iface = iface;
info.protocols = protocols;
#ifndef LWS_NO_EXTENSIONS
- info.extensions = libwebsocket_get_internal_extensions();
+ info.extensions = lws_get_internal_extensions();
#endif
if (use_ssl) {
info.ssl_cert_filepath = LOCAL_RESOURCE_PATH"/libwebsockets-test-server.pem";
@@ -328,7 +328,7 @@ int main(int argc, char **argv)
info.uid = -1;
info.options = opts;
- context = libwebsocket_create_context(&info);
+ context = lws_create_context(&info);
if (context == NULL) {
fprintf(stderr, "libwebsocket init failed\n");
return -1;
@@ -337,7 +337,7 @@ int main(int argc, char **argv)
if (client) {
address = argv[optind];
fprintf(stderr, "Connecting to %s:%u\n", address, port);
- wsi = libwebsocket_client_connect(context, address,
+ wsi = lws_client_connect(context, address,
port, use_ssl, "/", address,
"origin", protocols[PROTOCOL_FRAGGLE].name,
-1);
@@ -349,12 +349,12 @@ int main(int argc, char **argv)
n = 0;
while (!n && !terminate)
- n = libwebsocket_service(context, 50);
+ n = lws_service(context, 50);
fprintf(stderr, "Terminating...\n");
bail:
- libwebsocket_context_destroy(context);
+ lws_context_destroy(context);
return 0;
}
diff --git a/test-server/test-ping.c b/test-server/test-ping.c
index d5b7c8e3..6dcea97b 100644
--- a/test-server/test-ping.c
+++ b/test-server/test-ping.c
@@ -144,7 +144,7 @@ callback_lws_mirror(struct libwebsocket_context * this,
* LWS_CALLBACK_CLIENT_WRITEABLE will come next service
*/
- libwebsocket_callback_on_writable(this, wsi);
+ lws_callback_on_writable(this, wsi);
break;
case LWS_CALLBACK_CLIENT_RECEIVE:
@@ -256,11 +256,11 @@ callback_lws_mirror(struct libwebsocket_context * this,
global_tx_count++;
if (use_mirror)
- n = libwebsocket_write(wsi,
+ n = lws_write(wsi,
&pingbuf[LWS_SEND_BUFFER_PRE_PADDING],
size, write_options | LWS_WRITE_BINARY);
else
- n = libwebsocket_write(wsi,
+ n = lws_write(wsi,
&pingbuf[LWS_SEND_BUFFER_PRE_PADDING],
size, write_options | LWS_WRITE_PING);
@@ -426,12 +426,12 @@ int main(int argc, char **argv)
info.port = CONTEXT_PORT_NO_LISTEN;
info.protocols = protocols;
#ifndef LWS_NO_EXTENSIONS
- info.extensions = libwebsocket_get_internal_extensions();
+ info.extensions = lws_get_internal_extensions();
#endif
info.gid = -1;
info.uid = -1;
- context = libwebsocket_create_context(&info);
+ context = lws_create_context(&info);
if (context == NULL) {
fprintf(stderr, "Creating libwebsocket context failed\n");
return 1;
@@ -440,7 +440,7 @@ int main(int argc, char **argv)
/* create client websockets using dumb increment protocol */
for (n = 0; n < clients; n++) {
- ping_wsi[n] = libwebsocket_client_connect(context, address,
+ ping_wsi[n] = lws_client_connect(context, address,
port, use_ssl, "/", address,
"origin", protocols[PROTOCOL_LWS_MIRROR].name,
ietf_version);
@@ -451,8 +451,8 @@ int main(int argc, char **argv)
}
}
- libwebsockets_get_peer_addresses(context, ping_wsi[0],
- libwebsocket_get_socket_fd(ping_wsi[0]),
+ lws_get_peer_addresses(context, ping_wsi[0],
+ lws_get_socket_fd(ping_wsi[0]),
peer_name, sizeof peer_name, ip, sizeof ip);
fprintf(stderr, "Websocket PING %s (%s) %d bytes of data.\n",
@@ -487,7 +487,7 @@ int main(int argc, char **argv)
if (!interrupted_time) {
if ((l - oldus) > interval_us) {
for (n = 0; n < clients; n++)
- libwebsocket_callback_on_writable(
+ lws_callback_on_writable(
context, ping_wsi[n]);
oldus = l;
}
@@ -501,9 +501,9 @@ int main(int argc, char **argv)
}
if (!interval_us)
- n = libwebsocket_service(context, 0);
+ n = lws_service(context, 0);
else
- n = libwebsocket_service(context, 1);
+ n = lws_service(context, 1);
}
/* stats */
@@ -523,7 +523,7 @@ int main(int argc, char **argv)
((double)global_rx_count * (double)size) /
((double)(l - started) / 1000000.0) / 1024.0);
- libwebsocket_context_destroy(context);
+ lws_context_destroy(context);
return 0;
diff --git a/test-server/test-server-dumb-increment.c b/test-server/test-server-dumb-increment.c
index 81af06dc..18a81468 100644
--- a/test-server/test-server-dumb-increment.c
+++ b/test-server/test-server-dumb-increment.c
@@ -43,7 +43,7 @@ callback_dumb_increment(struct libwebsocket_context *context,
case LWS_CALLBACK_SERVER_WRITEABLE:
n = sprintf((char *)p, "%d", pss->number++);
- m = libwebsocket_write(wsi, p, n, LWS_WRITE_TEXT);
+ m = lws_write(wsi, p, n, LWS_WRITE_TEXT);
if (m < n) {
lwsl_err("ERROR %d writing to di socket\n", n);
return -1;
diff --git a/test-server/test-server-http.c b/test-server/test-server-http.c
index 9c72e58e..26aa4e09 100644
--- a/test-server/test-server-http.c
+++ b/test-server/test-server-http.c
@@ -139,14 +139,14 @@ int callback_http(struct libwebsocket_context *context,
dump_handshake_info(wsi);
if (len < 1) {
- libwebsockets_return_http_status(context, wsi,
+ lws_return_http_status(context, wsi,
HTTP_STATUS_BAD_REQUEST, NULL);
goto try_to_reuse;
}
/* this example server has no concept of directories */
if (strchr((const char *)in + 1, '/')) {
- libwebsockets_return_http_status(context, wsi,
+ lws_return_http_status(context, wsi,
HTTP_STATUS_FORBIDDEN, NULL);
goto try_to_reuse;
}
@@ -217,7 +217,7 @@ int callback_http(struct libwebsocket_context *context,
* this is mandated by changes in HTTP2
*/
- n = libwebsocket_write(wsi,
+ n = lws_write(wsi,
buffer + LWS_SEND_BUFFER_PRE_PADDING,
p - (buffer + LWS_SEND_BUFFER_PRE_PADDING),
LWS_WRITE_HTTP_HEADERS);
@@ -229,7 +229,7 @@ int callback_http(struct libwebsocket_context *context,
/*
* book us a LWS_CALLBACK_HTTP_WRITEABLE callback
*/
- libwebsocket_callback_on_writable(context, wsi);
+ lws_callback_on_writable(context, wsi);
break;
}
@@ -247,7 +247,7 @@ int callback_http(struct libwebsocket_context *context,
mimetype = get_mimetype(buf);
if (!mimetype) {
lwsl_err("Unknown mimetype for %s\n", buf);
- libwebsockets_return_http_status(context, wsi,
+ lws_return_http_status(context, wsi,
HTTP_STATUS_UNSUPPORTED_MEDIA_TYPE, NULL);
return -1;
}
@@ -275,7 +275,7 @@ int callback_http(struct libwebsocket_context *context,
other_headers = leaf_path;
}
- n = libwebsockets_serve_http_file(context, wsi, buf,
+ n = lws_serve_http_file(context, wsi, buf,
mimetype, other_headers, n);
if (n < 0 || ((n > 0) && lws_http_transaction_completed(wsi)))
return -1; /* error or can't reuse connection: close the socket */
@@ -302,7 +302,7 @@ int callback_http(struct libwebsocket_context *context,
case LWS_CALLBACK_HTTP_BODY_COMPLETION:
lwsl_notice("LWS_CALLBACK_HTTP_BODY_COMPLETION\n");
/* the whole of the sent body arrived, close or reuse the connection */
- libwebsockets_return_http_status(context, wsi,
+ lws_return_http_status(context, wsi,
HTTP_STATUS_OK, NULL);
goto try_to_reuse;
@@ -344,7 +344,7 @@ int callback_http(struct libwebsocket_context *context,
* is handled by the library itself if you sent a
* content-length header
*/
- m = libwebsocket_write(wsi,
+ m = lws_write(wsi,
buffer + LWS_SEND_BUFFER_PRE_PADDING,
n, LWS_WRITE_HTTP);
if (m < 0)
@@ -360,7 +360,7 @@ int callback_http(struct libwebsocket_context *context,
goto bail;
if (m) /* while still active, extend timeout */
- libwebsocket_set_timeout(wsi,
+ lws_set_timeout(wsi,
PENDING_TIMEOUT_HTTP_CONTENT, 5);
/* if we have indigestion, let him clear it before eating more */
@@ -370,12 +370,12 @@ int callback_http(struct libwebsocket_context *context,
} while (!lws_send_pipe_choked(wsi));
later:
- libwebsocket_callback_on_writable(context, wsi);
+ lws_callback_on_writable(context, wsi);
break;
flush_bail:
/* true if still partial pending */
if (lws_partial_buffered(wsi)) {
- libwebsocket_callback_on_writable(context, wsi);
+ lws_callback_on_writable(context, wsi);
break;
}
close(pss->fd);
@@ -450,7 +450,7 @@ bail:
case LWS_CALLBACK_GET_THREAD_ID:
/*
- * if you will call "libwebsocket_callback_on_writable"
+ * if you will call "lws_callback_on_writable"
* from a different thread, return the caller thread ID
* here so lws can use this information to work out if it
* should signal the poll() loop to exit and restart early
diff --git a/test-server/test-server-mirror.c b/test-server/test-server-mirror.c
index ced499d4..e1f5e492 100644
--- a/test-server/test-server-mirror.c
+++ b/test-server/test-server-mirror.c
@@ -62,7 +62,7 @@ callback_lws_mirror(struct libwebsocket_context *context,
break;
while (pss->ringbuffer_tail != ringbuffer_head) {
- n = libwebsocket_write(wsi, (unsigned char *)
+ n = lws_write(wsi, (unsigned char *)
ringbuffer[pss->ringbuffer_tail].payload +
LWS_SEND_BUFFER_PRE_PADDING,
ringbuffer[pss->ringbuffer_tail].len,
@@ -82,11 +82,11 @@ callback_lws_mirror(struct libwebsocket_context *context,
if (((ringbuffer_head - pss->ringbuffer_tail) &
(MAX_MESSAGE_QUEUE - 1)) == (MAX_MESSAGE_QUEUE - 15))
- libwebsocket_rx_flow_allow_all_protocol(
- libwebsockets_get_protocol(wsi));
+ lws_rx_flow_allow_all_protocol(
+ lws_get_protocol(wsi));
if (lws_partial_buffered(wsi) || lws_send_pipe_choked(wsi)) {
- libwebsocket_callback_on_writable(context, wsi);
+ lws_callback_on_writable(context, wsi);
break;
}
/*
@@ -128,11 +128,11 @@ callback_lws_mirror(struct libwebsocket_context *context,
choke:
lwsl_debug("LWS_CALLBACK_RECEIVE: throttling %p\n", wsi);
- libwebsocket_rx_flow_control(wsi, 0);
+ lws_rx_flow_control(wsi, 0);
done:
- libwebsocket_callback_on_writable_all_protocol(
- libwebsockets_get_protocol(wsi));
+ lws_callback_on_writable_all_protocol(
+ lws_get_protocol(wsi));
break;
/*
diff --git a/test-server/test-server-pthreads.c b/test-server/test-server-pthreads.c
index 8385347b..7c60871a 100644
--- a/test-server/test-server-pthreads.c
+++ b/test-server/test-server-pthreads.c
@@ -37,7 +37,7 @@ struct libwebsocket_context *context;
* This mutex lock protects code that changes or relies on wsi list outside of
* the service thread. The service thread will acquire it when changing the
* wsi list and other threads should acquire it while dereferencing wsis or
- * calling apis like libwebsocket_callback_on_writable_all_protocol() which
+ * calling apis like lws_callback_on_writable_all_protocol() which
* use the wsi list and wsis from a different thread context.
*/
pthread_mutex_t lock_established_conns;
@@ -123,7 +123,7 @@ void *thread_dumb_increment(void *threadid)
* them is protected by the same lock
*/
pthread_mutex_lock(&lock_established_conns);
- libwebsocket_callback_on_writable_all_protocol(
+ lws_callback_on_writable_all_protocol(
&protocols[PROTOCOL_DUMB_INCREMENT]);
pthread_mutex_unlock(&lock_established_conns);
usleep(100000);
@@ -135,7 +135,7 @@ void *thread_dumb_increment(void *threadid)
void sighandler(int sig)
{
force_exit = 1;
- libwebsocket_cancel_service(context);
+ lws_cancel_service(context);
}
static struct option options[] = {
@@ -276,7 +276,7 @@ int main(int argc, char **argv)
info.iface = iface;
info.protocols = protocols;
#ifndef LWS_NO_EXTENSIONS
- info.extensions = libwebsocket_get_internal_extensions();
+ info.extensions = lws_get_internal_extensions();
#endif
info.ssl_cert_filepath = NULL;
@@ -303,7 +303,7 @@ int main(int argc, char **argv)
info.uid = -1;
info.options = opts;
- context = libwebsocket_create_context(&info);
+ context = lws_create_context(&info);
if (context == NULL) {
lwsl_err("libwebsocket init failed\n");
return -1;
@@ -321,14 +321,14 @@ int main(int argc, char **argv)
n = 0;
while (n >= 0 && !force_exit) {
- n = libwebsocket_service(context, 50);
+ n = lws_service(context, 50);
}
/* wait for pthread_dumb to exit */
pthread_join(pthread_dumb, &retval);
done:
- libwebsocket_context_destroy(context);
+ lws_context_destroy(context);
pthread_mutex_destroy(&lock_established_conns);
diff --git a/test-server/test-server.c b/test-server/test-server.c
index 4b2dfb7f..de05ee83 100644
--- a/test-server/test-server.c
+++ b/test-server/test-server.c
@@ -100,7 +100,7 @@ static struct libwebsocket_protocols protocols[] = {
void sighandler(int sig)
{
force_exit = 1;
- libwebsocket_cancel_service(context);
+ lws_cancel_service(context);
}
static struct option options[] = {
@@ -238,7 +238,7 @@ int main(int argc, char **argv)
info.iface = iface;
info.protocols = protocols;
#ifndef LWS_NO_EXTENSIONS
- info.extensions = libwebsocket_get_internal_extensions();
+ info.extensions = lws_get_internal_extensions();
#endif
info.ssl_cert_filepath = NULL;
@@ -265,7 +265,7 @@ int main(int argc, char **argv)
info.uid = -1;
info.options = opts;
- context = libwebsocket_create_context(&info);
+ context = lws_create_context(&info);
if (context == NULL) {
lwsl_err("libwebsocket init failed\n");
return -1;
@@ -285,7 +285,7 @@ int main(int argc, char **argv)
ms = (tv.tv_sec * 1000) + (tv.tv_usec / 1000);
if ((ms - oldms) > 50) {
- libwebsocket_callback_on_writable_all_protocol(
+ lws_callback_on_writable_all_protocol(
&protocols[PROTOCOL_DUMB_INCREMENT]);
oldms = ms;
}
@@ -308,7 +308,7 @@ int main(int argc, char **argv)
* match anything under libwebsockets
* control
*/
- if (libwebsocket_service_fd(context,
+ if (lws_service_fd(context,
&pollfds[n]) < 0)
goto done;
#else
@@ -321,7 +321,7 @@ int main(int argc, char **argv)
* the number of ms in the second argument.
*/
- n = libwebsocket_service(context, 50);
+ n = lws_service(context, 50);
#endif
}
@@ -329,7 +329,7 @@ int main(int argc, char **argv)
done:
#endif
- libwebsocket_context_destroy(context);
+ lws_context_destroy(context);
lwsl_notice("libwebsockets-test-server exited cleanly\n");