api rationalization eliminate oldstyle internal api names
Between changing to lws_ a few years ago and the previous two
patches migrating the public apis, there are only a few
internal functions left using libwebsocket_*.
Change those to also use lws_ without regard to compatibility
since they were never visible outside the library.
Signed-off-by: Andy Green <andy.green@linaro.org>
diff --git a/lib/client-handshake.c b/lib/client-handshake.c
index 8bfec2d..7c642eb 100644
--- a/lib/client-handshake.c
+++ b/lib/client-handshake.c
@@ -308,7 +308,7 @@
return NULL;
failed:
- libwebsocket_close_and_free_session(context, wsi,
+ lws_close_and_free_session(context, wsi,
LWS_CLOSE_STATUS_NOSTATUS);
return NULL;
}
diff --git a/lib/client-parser.c b/lib/client-parser.c
index 567f5ca..0795926 100644
--- a/lib/client-parser.c
+++ b/lib/client-parser.c
@@ -21,7 +21,7 @@
#include "private-libwebsockets.h"
-int libwebsocket_client_rx_sm(struct libwebsocket *wsi, unsigned char c)
+int lws_client_rx_sm(struct libwebsocket *wsi, unsigned char c)
{
int callback_action = LWS_CALLBACK_CLIENT_RECEIVE;
int handled;
diff --git a/lib/client.c b/lib/client.c
index 29ee3c9..293df31 100644
--- a/lib/client.c
+++ b/lib/client.c
@@ -32,7 +32,7 @@
case LWS_CONNMODE_WS_CLIENT_WAITING_EXTENSION_CONNECT:
case LWS_CONNMODE_WS_CLIENT:
for (n = 0; n < len; n++)
- if (libwebsocket_client_rx_sm(wsi, *(*buf)++)) {
+ if (lws_client_rx_sm(wsi, *(*buf)++)) {
lwsl_debug("client_rx_sm failed\n");
return 1;
}
@@ -78,7 +78,7 @@
lwsl_warn("Proxy connection %p (fd=%d) dead\n",
(void *)wsi, pollfd->fd);
- libwebsocket_close_and_free_session(context, wsi,
+ lws_close_and_free_session(context, wsi,
LWS_CLOSE_STATUS_NOSTATUS);
return 0;
}
@@ -93,7 +93,7 @@
return 0;
}
- libwebsocket_close_and_free_session(context, wsi,
+ lws_close_and_free_session(context, wsi,
LWS_CLOSE_STATUS_NOSTATUS);
lwsl_err("ERROR reading from proxy socket\n");
return 0;
@@ -103,7 +103,7 @@
if (strcmp((char *)context->service_buffer, "HTTP/1.0 200 ") &&
strcmp((char *)context->service_buffer, "HTTP/1.1 200 ")
) {
- libwebsocket_close_and_free_session(context, wsi,
+ lws_close_and_free_session(context, wsi,
LWS_CLOSE_STATUS_NOSTATUS);
lwsl_err("ERROR proxy: %s\n", context->service_buffer);
return 0;
@@ -336,7 +336,7 @@
} else {
lwsl_err("server's cert didn't look good, X509_V_ERR = %d: %s\n",
n, ERR_error_string(n, (char *)context->service_buffer));
- libwebsocket_close_and_free_session(context,
+ lws_close_and_free_session(context,
wsi, LWS_CLOSE_STATUS_NOSTATUS);
return 0;
}
@@ -354,10 +354,10 @@
/* fallthru */
case LWS_CONNMODE_WS_CLIENT_ISSUE_HANDSHAKE2:
- p = libwebsockets_generate_client_handshake(context, wsi, p);
+ p = lws_generate_client_handshake(context, wsi, p);
if (p == NULL) {
lwsl_err("Failed to generate handshake for client\n");
- libwebsocket_close_and_free_session(context, wsi,
+ lws_close_and_free_session(context, wsi,
LWS_CLOSE_STATUS_NOSTATUS);
return 0;
}
@@ -371,7 +371,7 @@
switch (n) {
case LWS_SSL_CAPABLE_ERROR:
lwsl_debug("ERROR writing to client socket\n");
- libwebsocket_close_and_free_session(context, wsi,
+ lws_close_and_free_session(context, wsi,
LWS_CLOSE_STATUS_NOSTATUS);
return 0;
case LWS_SSL_CAPABLE_MORE_SERVICE:
@@ -433,7 +433,7 @@
return 0;
}
- if (libwebsocket_parse(context, wsi, c)) {
+ if (lws_parse(context, wsi, c)) {
lwsl_warn("problems parsing header\n");
goto bail3;
}
@@ -459,7 +459,7 @@
bail3:
lwsl_info(
"closing connection at LWS_CONNMODE...SERVER_REPLY\n");
- libwebsocket_close_and_free_session(context, wsi,
+ lws_close_and_free_session(context, wsi,
LWS_CLOSE_STATUS_NOSTATUS);
return -1;
@@ -724,7 +724,7 @@
}
/* allocate the per-connection user memory (if any) */
- if (libwebsocket_ensure_user_space(wsi)) {
+ if (lws_ensure_user_space(wsi)) {
lwsl_err("Problem allocating wsi user mem\n");
goto bail2;
}
@@ -825,14 +825,14 @@
lws_free2(wsi->u.hdr.ah);
- libwebsocket_close_and_free_session(context, wsi, close_reason);
+ lws_close_and_free_session(context, wsi, close_reason);
return 1;
}
char *
-libwebsockets_generate_client_handshake(struct libwebsocket_context *context,
+lws_generate_client_handshake(struct libwebsocket_context *context,
struct libwebsocket *wsi, char *pkt)
{
char buf[128];
@@ -853,7 +853,7 @@
if (n != 16) {
lwsl_err("Unable to read from random dev %s\n",
SYSTEM_RANDOM_FILEPATH);
- libwebsocket_close_and_free_session(context, wsi,
+ lws_close_and_free_session(context, wsi,
LWS_CLOSE_STATUS_NOSTATUS);
return NULL;
}
diff --git a/lib/context.c b/lib/context.c
index 71154a1..5ef85a2 100644
--- a/lib/context.c
+++ b/lib/context.c
@@ -292,7 +292,7 @@
wsi_from_fd(context, context->fds[n].fd);
if (!wsi)
continue;
- libwebsocket_close_and_free_session(context,
+ lws_close_and_free_session(context,
wsi, LWS_CLOSE_STATUS_NOSTATUS_CONTEXT_DESTROY /* no protocol close */);
n--;
}
diff --git a/lib/handshake.c b/lib/handshake.c
index d1e3f9c..229fb8c 100644
--- a/lib/handshake.c
+++ b/lib/handshake.c
@@ -191,7 +191,7 @@
switch (wsi->mode) {
case LWS_CONNMODE_WS_SERVING:
- if (libwebsocket_interpret_incoming_packet(wsi, buf, len) < 0) {
+ if (lws_interpret_incoming_packet(wsi, buf, len) < 0) {
lwsl_info("interpret_incoming_packet has bailed\n");
goto bail;
}
@@ -226,8 +226,7 @@
bail:
lwsl_debug("closing connection at lws_read bail:\n");
- libwebsocket_close_and_free_session(context, wsi,
- LWS_CLOSE_STATUS_NOSTATUS);
+ lws_close_and_free_session(context, wsi, LWS_CLOSE_STATUS_NOSTATUS);
return -1;
}
diff --git a/lib/hpack.c b/lib/hpack.c
index 3ac01b0..63c7595 100644
--- a/lib/hpack.c
+++ b/lib/hpack.c
@@ -540,7 +540,7 @@
if (lws_frag_append(wsi, c1))
return 1;
} else { /* name */
- if (libwebsocket_parse(context, wsi, c1))
+ if (lws_parse(context, wsi, c1))
return 1;
}
diff --git a/lib/http2.c b/lib/http2.c
index ffedb78..b73d8bf 100644
--- a/lib/http2.c
+++ b/lib/http2.c
@@ -54,7 +54,7 @@
struct libwebsocket *
lws_create_server_child_wsi(struct libwebsocket_context *context, struct libwebsocket *parent_wsi, unsigned int sid)
{
- struct libwebsocket *wsi = libwebsocket_create_new_server_wsi(context);
+ struct libwebsocket *wsi = lws_create_new_server_wsi(context);
if (!wsi)
return NULL;
@@ -80,7 +80,7 @@
wsi->mode = parent_wsi->mode;
wsi->protocol = &context->protocols[0];
- libwebsocket_ensure_user_space(wsi);
+ lws_ensure_user_space(wsi);
lwsl_info("%s: %p new child %p, sid %d, user_space=%p\n", __func__, parent_wsi, wsi, sid, wsi->user_space);
diff --git a/lib/libev.c b/lib/libev.c
index 203a0fb..323e2aa 100644
--- a/lib/libev.c
+++ b/lib/libev.c
@@ -30,7 +30,7 @@
}
static void
-libwebsocket_accept_cb(struct ev_loop *loop, struct ev_io *watcher, int revents)
+lws_accept_cb(struct ev_loop *loop, struct ev_io *watcher, int revents)
{
struct libwebsocket_pollfd eventfd;
struct lws_io_watcher *lws_io = container_of(watcher, struct lws_io_watcher, watcher);
@@ -92,7 +92,7 @@
* Initialize the accept w_accept with the listening socket
* and register a callback for read operations:
*/
- ev_io_init(w_accept, libwebsocket_accept_cb,
+ ev_io_init(w_accept, lws_accept_cb,
context->listen_service_fd, EV_READ);
ev_io_start(context->io_loop,w_accept);
@@ -144,8 +144,8 @@
new_wsi->w_read.context = context;
new_wsi->w_write.context = context;
- ev_io_init(r, libwebsocket_accept_cb, accept_fd, EV_READ);
- ev_io_init(w, libwebsocket_accept_cb, accept_fd, EV_WRITE);
+ ev_io_init(r, lws_accept_cb, accept_fd, EV_READ);
+ ev_io_init(w, lws_accept_cb, accept_fd, EV_WRITE);
}
LWS_VISIBLE void
diff --git a/lib/libwebsockets.c b/lib/libwebsockets.c
index 9cdd29a..a4fb792 100644
--- a/lib/libwebsockets.c
+++ b/lib/libwebsockets.c
@@ -61,7 +61,7 @@
}
void
-libwebsocket_close_and_free_session(struct libwebsocket_context *context,
+lws_close_and_free_session(struct libwebsocket_context *context,
struct libwebsocket *wsi, enum lws_close_status reason)
{
int n, m, ret;
@@ -324,7 +324,7 @@
}
LWS_VISIBLE int
-libwebsockets_get_addresses(struct libwebsocket_context *context,
+lws_get_addresses(struct libwebsocket_context *context,
void *ads, char *name, int name_len,
char *rip, int rip_len)
{
@@ -456,7 +456,7 @@
goto bail;
}
- ret = libwebsockets_get_addresses(context, p, name, name_len, rip, rip_len);
+ ret = lws_get_addresses(context, p, name, name_len, rip, rip_len);
bail:
lws_latency(context, wsi, "lws_get_peer_addresses", ret, 1);
@@ -782,7 +782,7 @@
}
int
-libwebsocket_ensure_user_space(struct libwebsocket *wsi)
+lws_ensure_user_space(struct libwebsocket *wsi)
{
lwsl_info("%s: %p protocol %p\n", __func__, wsi, wsi->protocol);
if (!wsi->protocol)
diff --git a/lib/lws-plat-mbed3.cpp b/lib/lws-plat-mbed3.cpp
index e0f5b93..7d5ddc2 100644
--- a/lib/lws-plat-mbed3.cpp
+++ b/lib/lws-plat-mbed3.cpp
@@ -299,7 +299,7 @@
void lws_conn::onDisconnect(TCPStream *s)
{
(void)s;
- libwebsocket_close_and_free_session(wsi->protocol->owning_server, wsi,
+ lws_close_and_free_session(wsi->protocol->owning_server, wsi,
LWS_CLOSE_STATUS_NOSTATUS);
}
diff --git a/lib/output.c b/lib/output.c
index 16fd1e9..42261cd 100644
--- a/lib/output.c
+++ b/lib/output.c
@@ -22,7 +22,7 @@
#include "private-libwebsockets.h"
static int
-libwebsocket_0405_frame_mask_generate(struct libwebsocket *wsi)
+lws_0405_frame_mask_generate(struct libwebsocket *wsi)
{
int n;
@@ -411,7 +411,7 @@
if (wsi->mode == LWS_CONNMODE_WS_CLIENT) {
if (!wsi->u.ws.inside_frame)
- if (libwebsocket_0405_frame_mask_generate(wsi)) {
+ if (lws_0405_frame_mask_generate(wsi)) {
lwsl_err("frame mask generation failed\n");
return -1;
}
diff --git a/lib/parsers.c b/lib/parsers.c
index 83124ff..c7b47d4 100644
--- a/lib/parsers.c
+++ b/lib/parsers.c
@@ -206,7 +206,7 @@
return 1;
}
-int libwebsocket_parse(
+int lws_parse(
struct libwebsocket_context *context,
struct libwebsocket *wsi, unsigned char c)
{
@@ -281,7 +281,7 @@
issue_char(wsi, '%');
wsi->u.hdr.ues = URIES_IDLE;
/* regurgitate + assess */
- if (libwebsocket_parse(context, wsi, wsi->u.hdr.esc_stash) < 0)
+ if (lws_parse(context, wsi, wsi->u.hdr.esc_stash) < 0)
return -1;
/* continue on to assess c */
break;
@@ -578,7 +578,7 @@
}
int
-libwebsocket_rx_sm(struct libwebsocket *wsi, unsigned char c)
+lws_rx_sm(struct libwebsocket *wsi, unsigned char c)
{
struct lws_tokens eff_buf;
int ret = 0;
diff --git a/lib/private-libwebsockets.h b/lib/private-libwebsockets.h
index b24354f..01fcbea 100644
--- a/lib/private-libwebsockets.h
+++ b/lib/private-libwebsockets.h
@@ -459,7 +459,7 @@
#ifdef _WIN32
#define LWS_FD_HASH(fd) ((fd ^ (fd >> 8) ^ (fd >> 16)) % FD_HASHTABLE_MODULUS)
-struct libwebsocket_fd_hashtable {
+struct lws_fd_hashtable {
struct libwebsocket **wsi;
int length;
};
@@ -472,7 +472,7 @@
struct libwebsocket_pollfd *fds;
#ifdef _WIN32
/* different implementation between unix and windows */
- struct libwebsocket_fd_hashtable fd_hashtable[FD_HASHTABLE_MODULUS];
+ struct lws_fd_hashtable fd_hashtable[FD_HASHTABLE_MODULUS];
#else
struct libwebsocket **lws_lookup; /* fd to wsi */
#endif
@@ -922,7 +922,7 @@
LWS_EXTERN int log_level;
LWS_EXTERN void
-libwebsocket_close_and_free_session(struct libwebsocket_context *context,
+lws_close_and_free_session(struct libwebsocket_context *context,
struct libwebsocket *wsi, enum lws_close_status);
LWS_EXTERN int
@@ -949,10 +949,10 @@
struct libwebsocket *wsi,
enum lws_pending_protocol_send pend);
LWS_EXTERN int
-libwebsocket_client_rx_sm(struct libwebsocket *wsi, unsigned char c);
+lws_client_rx_sm(struct libwebsocket *wsi, unsigned char c);
LWS_EXTERN int
-libwebsocket_parse(struct libwebsocket_context *context,
+lws_parse(struct libwebsocket_context *context,
struct libwebsocket *wsi, unsigned char c);
LWS_EXTERN int
@@ -993,10 +993,10 @@
struct libwebsocket *wsi);
LWS_EXTERN struct libwebsocket *
-libwebsocket_create_new_server_wsi(struct libwebsocket_context *context);
+lws_create_new_server_wsi(struct libwebsocket_context *context);
LWS_EXTERN char *
-libwebsockets_generate_client_handshake(struct libwebsocket_context *context,
+lws_generate_client_handshake(struct libwebsocket_context *context,
struct libwebsocket *wsi, char *pkt);
LWS_EXTERN int
@@ -1037,7 +1037,7 @@
struct libwebsocket *wsi);
LWS_EXTERN int
-libwebsocket_rx_sm(struct libwebsocket *wsi, unsigned char c);
+lws_rx_sm(struct libwebsocket *wsi, unsigned char c);
LWS_EXTERN int
lws_issue_raw_ext_access(struct libwebsocket *wsi,
@@ -1116,7 +1116,7 @@
enum lws_token_indexes h, const char *s);
LWS_EXTERN int
-libwebsocket_ensure_user_space(struct libwebsocket *wsi);
+lws_ensure_user_space(struct libwebsocket *wsi);
LWS_EXTERN int
lws_change_pollfd(struct libwebsocket *wsi, int _and, int _or);
@@ -1127,14 +1127,14 @@
LWS_EXTERN int handshake_0405(struct libwebsocket_context *context,
struct libwebsocket *wsi);
LWS_EXTERN int
-libwebsocket_interpret_incoming_packet(struct libwebsocket *wsi,
+lws_interpret_incoming_packet(struct libwebsocket *wsi,
unsigned char *buf, size_t len);
LWS_EXTERN void
lws_server_get_canonical_hostname(struct libwebsocket_context *context,
struct lws_context_creation_info *info);
#else
#define lws_context_init_server(_a, _b) (0)
-#define libwebsocket_interpret_incoming_packet(_a, _b, _c) (0)
+#define lws_interpret_incoming_packet(_a, _b, _c) (0)
#define lws_server_get_canonical_hostname(_a, _b)
#endif
@@ -1236,7 +1236,7 @@
#endif
LWS_EXTERN int lws_handshake_client(struct libwebsocket *wsi, unsigned char **buf, size_t len);
LWS_EXTERN void
- libwebsockets_decode_ssl_error(void);
+ lws_decode_ssl_error(void);
#else
#define lws_context_init_client_ssl(_a, _b) (0)
#define lws_handshake_client(_a, _b, _c) (0)
@@ -1254,7 +1254,7 @@
#define lws_handshake_server(_a, _b, _c, _d) (0)
#endif
-LWS_EXTERN int libwebsockets_get_addresses(struct libwebsocket_context *context,
+LWS_EXTERN int lws_get_addresses(struct libwebsocket_context *context,
void *ads, char *name, int name_len,
char *rip, int rip_len);
diff --git a/lib/server-handshake.c b/lib/server-handshake.c
index 2e2cf5c..5962cd8 100644
--- a/lib/server-handshake.c
+++ b/lib/server-handshake.c
@@ -196,7 +196,7 @@
}
/* allocate the per-connection user memory (if any) */
- if (libwebsocket_ensure_user_space(wsi))
+ if (lws_ensure_user_space(wsi))
goto bail;
/* create the response packet */
diff --git a/lib/server.c b/lib/server.c
index 7522ef5..d295fcd 100644
--- a/lib/server.c
+++ b/lib/server.c
@@ -234,7 +234,7 @@
goto bail_nuke_ah;
}
- if (libwebsocket_ensure_user_space(wsi))
+ if (lws_ensure_user_space(wsi))
goto bail_nuke_ah;
for (n = 0; n < ARRAY_SIZE(methods); n++)
@@ -356,15 +356,15 @@
/* LWS_CONNMODE_WS_SERVING */
while (len--) {
- if (libwebsocket_parse(context, wsi, *(*buf)++)) {
- lwsl_info("libwebsocket_parse failed\n");
+ if (lws_parse(context, wsi, *(*buf)++)) {
+ lwsl_info("lws_parse failed\n");
goto bail_nuke_ah;
}
if (wsi->u.hdr.parser_state != WSI_PARSING_COMPLETE)
continue;
- lwsl_parser("libwebsocket_parse sees parsing complete\n");
+ lwsl_parser("lws_parse sees parsing complete\n");
wsi->mode = LWS_CONNMODE_PRE_WS_SERVING_ACCEPT;
lws_set_timeout(wsi, NO_PENDING_TIMEOUT, 0);
@@ -520,7 +520,7 @@
}
/* allocate wsi->user storage */
- if (libwebsocket_ensure_user_space(wsi))
+ if (lws_ensure_user_space(wsi))
goto bail_nuke_ah;
/*
@@ -597,7 +597,7 @@
}
struct libwebsocket *
-libwebsocket_create_new_server_wsi(struct libwebsocket_context *context)
+lws_create_new_server_wsi(struct libwebsocket_context *context)
{
struct libwebsocket *new_wsi;
@@ -737,7 +737,7 @@
lws_free_header_table(wsi);
/* fallthru */
case LWS_SSL_CAPABLE_ERROR:
- libwebsocket_close_and_free_session(
+ lws_close_and_free_session(
context, wsi,
LWS_CLOSE_STATUS_NOSTATUS);
return 0;
@@ -836,7 +836,7 @@
break;
}
- new_wsi = libwebsocket_create_new_server_wsi(context);
+ new_wsi = lws_create_new_server_wsi(context);
if (new_wsi == NULL) {
compatible_close(accept_fd);
break;
@@ -885,7 +885,7 @@
return 0;
fail:
- libwebsocket_close_and_free_session(context, wsi,
+ lws_close_and_free_session(context, wsi,
LWS_CLOSE_STATUS_NOSTATUS);
return 1;
}
@@ -963,7 +963,7 @@
}
-int libwebsocket_interpret_incoming_packet(struct libwebsocket *wsi,
+int lws_interpret_incoming_packet(struct libwebsocket *wsi,
unsigned char *buf, size_t len)
{
size_t n = 0;
@@ -991,7 +991,7 @@
wsi->rxflow_pos++;
/* process the byte */
- m = libwebsocket_rx_sm(wsi, buf[n++]);
+ m = lws_rx_sm(wsi, buf[n++]);
if (m < 0)
return -1;
}
diff --git a/lib/service.c b/lib/service.c
index cc230d0..3430399 100644
--- a/lib/service.c
+++ b/lib/service.c
@@ -263,7 +263,7 @@
wsi2->u.http2.requested_POLLOUT = 0;
if (lws_calllback_as_writeable(context, wsi2)) {
lwsl_debug("Closing POLLOUT child\n");
- libwebsocket_close_and_free_session(context, wsi2,
+ lws_close_and_free_session(context, wsi2,
LWS_CLOSE_STATUS_NOSTATUS);
}
wsi2 = wsi;
@@ -307,7 +307,7 @@
* cleanup like flush partials.
*/
wsi->socket_is_permanently_unusable = 1;
- libwebsocket_close_and_free_session(context,
+ lws_close_and_free_session(context,
wsi, LWS_CLOSE_STATUS_NOSTATUS);
return 1;
}
@@ -632,7 +632,7 @@
close_and_handled:
lwsl_debug("Close and handled\n");
- libwebsocket_close_and_free_session(context, wsi,
+ lws_close_and_free_session(context, wsi,
LWS_CLOSE_STATUS_NOSTATUS);
// pollfd points to something else after the close
return 1;
diff --git a/lib/ssl.c b/lib/ssl.c
index 9a51cd8..21d1a3c 100644
--- a/lib/ssl.c
+++ b/lib/ssl.c
@@ -264,7 +264,7 @@
}
LWS_VISIBLE void
-libwebsockets_decode_ssl_error(void)
+lws_decode_ssl_error(void)
{
char buf[256];
u_long err;
@@ -550,7 +550,7 @@
if (new_wsi->ssl == NULL) {
lwsl_err("SSL_new failed: %s\n",
ERR_error_string(SSL_get_error(new_wsi->ssl, 0), NULL));
- libwebsockets_decode_ssl_error();
+ lws_decode_ssl_error();
// TODO: Shouldn't the caller handle this?
compatible_close(accept_fd);