mirror of
https://github.com/warmcat/libwebsockets.git
synced 2025-03-09 00:00:04 +01:00
compile in xcode, privatize debug macro
This commit is contained in:
parent
6cd1ea9b00
commit
4550f1d7b5
6 changed files with 81 additions and 79 deletions
|
@ -207,7 +207,7 @@ libwebsocket_client_connect(struct libwebsocket_context *context,
|
|||
}
|
||||
#endif
|
||||
|
||||
wsi = malloc(sizeof(struct libwebsocket));
|
||||
wsi = (struct libwebsocket *) malloc(sizeof(struct libwebsocket));
|
||||
if (wsi == NULL)
|
||||
goto bail1;
|
||||
|
||||
|
@ -235,18 +235,18 @@ libwebsocket_client_connect(struct libwebsocket_context *context,
|
|||
|
||||
/* copy parameters over so state machine has access */
|
||||
|
||||
wsi->c_path = malloc(strlen(path) + 1);
|
||||
wsi->c_path = (char *)malloc(strlen(path) + 1);
|
||||
if (wsi->c_path == NULL)
|
||||
goto bail1;
|
||||
strcpy(wsi->c_path, path);
|
||||
|
||||
wsi->c_host = malloc(strlen(host) + 1);
|
||||
wsi->c_host = (char *)malloc(strlen(host) + 1);
|
||||
if (wsi->c_host == NULL)
|
||||
goto oom1;
|
||||
strcpy(wsi->c_host, host);
|
||||
|
||||
if (origin) {
|
||||
wsi->c_origin = malloc(strlen(origin) + 1);
|
||||
wsi->c_origin = (char *)malloc(strlen(origin) + 1);
|
||||
strcpy(wsi->c_origin, origin);
|
||||
if (wsi->c_origin == NULL)
|
||||
goto oom2;
|
||||
|
@ -258,7 +258,7 @@ libwebsocket_client_connect(struct libwebsocket_context *context,
|
|||
const char *pc;
|
||||
struct libwebsocket_protocols *pp;
|
||||
|
||||
wsi->c_protocol = malloc(strlen(protocol) + 1);
|
||||
wsi->c_protocol = (char *)malloc(strlen(protocol) + 1);
|
||||
if (wsi->c_protocol == NULL)
|
||||
goto oom3;
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ lws_mux_subcommand_header(int cmd, int channel, unsigned char *pb, int len)
|
|||
|
||||
if (channel == 0) {
|
||||
muxdebug("lws_mux_subcommand_header: given ch 0\n");
|
||||
*((int *)0) = 0;
|
||||
assert(0);
|
||||
}
|
||||
|
||||
if (channel < 31)
|
||||
|
@ -92,7 +92,7 @@ static int lws_ext_x_google_mux__send_addchannel(
|
|||
|
||||
if (channel == 0) {
|
||||
muxdebug("lws_ext_x_google_mux__send_addchannel: given ch 0\n");
|
||||
*((int *)0) = 0;
|
||||
assert(0);
|
||||
}
|
||||
|
||||
wsi_child->ietf_spec_revision = wsi->ietf_spec_revision;
|
||||
|
@ -165,7 +165,7 @@ lws_extension_x_google_mux_parser(struct libwebsocket_context *context,
|
|||
|
||||
case LWS_EXT_XGM_STATE__MUX_BLOCK_1:
|
||||
// fprintf(stderr, "LWS_EXT_XGM_STATE__MUX_BLOCK_1: opc=%d channel=%d\n", c & 7, c >> 3);
|
||||
conn->block_subopcode = c & 7;
|
||||
conn->block_subopcode = (enum lws_ext_x_goole_mux__mux_opcodes)(c & 7);
|
||||
conn->block_subchannel = (c >> 3) & 0x1f;
|
||||
conn->ignore_cmd = 0;
|
||||
|
||||
|
@ -339,7 +339,7 @@ interpret:
|
|||
/* client: we received all server's ADD ack */
|
||||
|
||||
if (conn->block_subchannel != 1) {
|
||||
child_conn = lws_get_extension_user_matching_ext(
|
||||
child_conn = (struct lws_ext_x_google_mux_conn *) lws_get_extension_user_matching_ext(
|
||||
wsi_child, this_ext);
|
||||
muxdebug("Received server's ADD Channel ACK for "
|
||||
"subchannel %d child_conn=%p!\n",
|
||||
|
@ -444,7 +444,7 @@ bail2:
|
|||
/* reply with ADDCHANNEL to ack it */
|
||||
|
||||
wsi->xor_mask = xor_no_mask;
|
||||
child_conn = lws_get_extension_user_matching_ext(wsi_child,
|
||||
child_conn = (struct lws_ext_x_google_mux_conn *)lws_get_extension_user_matching_ext(wsi_child,
|
||||
this_ext);
|
||||
if (!child_conn) {
|
||||
fprintf(stderr, "wsi_child %p has no child conn!", (void *)wsi_child);
|
||||
|
@ -608,7 +608,7 @@ int lws_extension_callback_x_google_mux(
|
|||
int n;
|
||||
struct lws_tokens *eff_buf = (struct lws_tokens *)in;
|
||||
unsigned char *p = NULL;
|
||||
struct lws_ext_x_google_mux_context *mux_ctx =
|
||||
struct lws_ext_x_google_mux_context *mux_ctx = (struct lws_ext_x_google_mux_context *)
|
||||
ext->per_context_private_data;
|
||||
struct libwebsocket *wsi_parent;
|
||||
struct libwebsocket *wsi_child;
|
||||
|
@ -674,7 +674,7 @@ int lws_extension_callback_x_google_mux(
|
|||
continue;
|
||||
|
||||
muxdebug(" %s / %s\n", wsi_parent->c_address, (char *)in);
|
||||
if (strcmp(wsi_parent->c_address, in))
|
||||
if (strcmp((const char*)wsi_parent->c_address, (const char *)in))
|
||||
continue;
|
||||
muxdebug(" %u / %u\n", wsi_parent->c_port, (unsigned int)len);
|
||||
|
||||
|
@ -791,7 +791,7 @@ int lws_extension_callback_x_google_mux(
|
|||
parent_conn = conn;
|
||||
} else {
|
||||
|
||||
parent_conn = lws_get_extension_user_matching_ext(conn->wsi_parent, ext);
|
||||
parent_conn = (struct lws_ext_x_google_mux_conn *)lws_get_extension_user_matching_ext(conn->wsi_parent, ext);
|
||||
if (parent_conn == 0) {
|
||||
muxdebug("failed to get parent conn\n");
|
||||
break;
|
||||
|
@ -844,7 +844,7 @@ int lws_extension_callback_x_google_mux(
|
|||
} else {
|
||||
|
||||
wsi_parent = conn->wsi_parent;
|
||||
parent_conn = lws_get_extension_user_matching_ext(conn->wsi_parent, ext);
|
||||
parent_conn = (struct lws_ext_x_google_mux_conn *)lws_get_extension_user_matching_ext(conn->wsi_parent, ext);
|
||||
if (parent_conn == 0) {
|
||||
muxdebug("failed to get parent conn\n");
|
||||
break;
|
||||
|
@ -1046,7 +1046,7 @@ handle_additions:
|
|||
* get parent / transport mux context
|
||||
*/
|
||||
|
||||
parent_conn = lws_get_extension_user_matching_ext(conn->wsi_parent, ext);
|
||||
parent_conn = (struct lws_ext_x_google_mux_conn *)lws_get_extension_user_matching_ext(conn->wsi_parent, ext);
|
||||
if (parent_conn == 0) {
|
||||
muxdebug("failed to get parent conn\n");
|
||||
return 0;
|
||||
|
@ -1207,7 +1207,7 @@ handle_additions:
|
|||
|
||||
/* disallow deflate-stream if we are a mux child connection */
|
||||
|
||||
if (strcmp(in, "deflate-stream") == 0 &&
|
||||
if (strcmp((const char*)in, "deflate-stream") == 0 &&
|
||||
client_handshake_generation_is_for_mux_child) {
|
||||
|
||||
muxdebug("mux banned deflate-stream on child connection\n");
|
||||
|
|
|
@ -103,7 +103,7 @@ handshake_00(struct libwebsocket_context *context, struct libwebsocket *wsi)
|
|||
|
||||
/* make a buffer big enough for everything */
|
||||
|
||||
response = malloc(256 +
|
||||
response = (char *)malloc(256 +
|
||||
wsi->utf8_token[WSI_TOKEN_UPGRADE].token_len +
|
||||
wsi->utf8_token[WSI_TOKEN_CONNECTION].token_len +
|
||||
wsi->utf8_token[WSI_TOKEN_HOST].token_len +
|
||||
|
@ -174,8 +174,8 @@ handshake_00(struct libwebsocket_context *context, struct libwebsocket *wsi)
|
|||
|
||||
/* it's complete: go ahead and send it */
|
||||
|
||||
debug("issuing response packet %d len\n", (int)(p - response));
|
||||
#ifdef DEBUG
|
||||
_debug("issuing response packet %d len\n", (int)(p - response));
|
||||
#ifdef _DEBUG
|
||||
fwrite(response, 1, p - response, stderr);
|
||||
#endif
|
||||
n = libwebsocket_write(wsi, (unsigned char *)response,
|
||||
|
@ -233,7 +233,7 @@ handshake_0405(struct libwebsocket_context *context, struct libwebsocket *wsi)
|
|||
|
||||
if (!wsi->utf8_token[WSI_TOKEN_HOST].token_len ||
|
||||
!wsi->utf8_token[WSI_TOKEN_KEY].token_len) {
|
||||
debug("handshake_04 missing pieces\n");
|
||||
_debug("handshake_04 missing pieces\n");
|
||||
/* completed header processing, but missing some bits */
|
||||
goto bail;
|
||||
}
|
||||
|
@ -269,7 +269,7 @@ handshake_0405(struct libwebsocket_context *context, struct libwebsocket *wsi)
|
|||
|
||||
/* make a buffer big enough for everything */
|
||||
|
||||
response = malloc(256 +
|
||||
response = (char *)malloc(256 +
|
||||
wsi->utf8_token[WSI_TOKEN_UPGRADE].token_len +
|
||||
wsi->utf8_token[WSI_TOKEN_CONNECTION].token_len +
|
||||
wsi->utf8_token[WSI_TOKEN_PROTOCOL].token_len);
|
||||
|
@ -469,7 +469,7 @@ handshake_0405(struct libwebsocket_context *context, struct libwebsocket *wsi)
|
|||
|
||||
/* okay send the handshake response accepting the connection */
|
||||
|
||||
debug("issuing response packet %d len\n", (int)(p - response));
|
||||
_debug("issuing response packet %d len\n", (int)(p - response));
|
||||
#ifdef DEBUG
|
||||
fwrite(response, 1, p - response, stderr);
|
||||
#endif
|
||||
|
@ -549,8 +549,8 @@ libwebsocket_read(struct libwebsocket_context *context,
|
|||
/* fallthru */
|
||||
case WSI_STATE_HTTP_HEADERS:
|
||||
|
||||
debug("issuing %d bytes to parser\n", (int)len);
|
||||
#ifdef DEBUG
|
||||
_debug("issuing %d bytes to parser\n", (int)len);
|
||||
#ifdef _DEBUG
|
||||
fwrite(buf, 1, len, stderr);
|
||||
#endif
|
||||
|
||||
|
@ -665,7 +665,7 @@ libwebsocket_read(struct libwebsocket_context *context,
|
|||
break;
|
||||
case 4: /* 04 */
|
||||
wsi->xor_mask = xor_mask_04;
|
||||
debug("libwebsocket_parse calling handshake_04\n");
|
||||
_debug("libwebsocket_parse calling handshake_04\n");
|
||||
if (handshake_0405(context, wsi))
|
||||
goto bail;
|
||||
break;
|
||||
|
@ -675,7 +675,7 @@ libwebsocket_read(struct libwebsocket_context *context,
|
|||
case 8:
|
||||
case 13:
|
||||
wsi->xor_mask = xor_mask_05;
|
||||
debug("libwebsocket_parse calling handshake_04\n");
|
||||
_debug("libwebsocket_parse calling handshake_04\n");
|
||||
if (handshake_0405(context, wsi))
|
||||
goto bail;
|
||||
break;
|
||||
|
|
|
@ -503,7 +503,7 @@ int libwebsockets_get_random(struct libwebsocket_context *context,
|
|||
void *buf, int len)
|
||||
{
|
||||
int n;
|
||||
char *p = buf;
|
||||
char *p = (char *)buf;
|
||||
|
||||
#ifdef WIN32
|
||||
for (n = 0; n < len; n++)
|
||||
|
@ -702,7 +702,7 @@ notify_action:
|
|||
else
|
||||
n = LWS_CALLBACK_SERVER_WRITEABLE;
|
||||
|
||||
wsi->protocol->callback(context, wsi, n, wsi->user_space, NULL, 0);
|
||||
wsi->protocol->callback(context, wsi, (enum libwebsocket_callback_reasons) n, wsi->user_space, NULL, 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -747,7 +747,7 @@ libwebsocket_create_new_server_wsi(struct libwebsocket_context *context)
|
|||
struct libwebsocket *new_wsi;
|
||||
int n;
|
||||
|
||||
new_wsi = malloc(sizeof(struct libwebsocket));
|
||||
new_wsi = (struct libwebsocket *)malloc(sizeof(struct libwebsocket));
|
||||
if (new_wsi == NULL) {
|
||||
fprintf(stderr, "Out of memory for new connection\n");
|
||||
return NULL;
|
||||
|
@ -1411,7 +1411,7 @@ accept_ok:
|
|||
wsi->state = WSI_STATE_ESTABLISHED;
|
||||
wsi->mode = LWS_CONNMODE_WS_CLIENT;
|
||||
|
||||
debug("handshake OK for protocol %s\n", wsi->protocol->name);
|
||||
_debug("handshake OK for protocol %s\n", wsi->protocol->name);
|
||||
|
||||
/* call him back to inform him he is up */
|
||||
|
||||
|
@ -1615,7 +1615,7 @@ libwebsocket_service_fd(struct libwebsocket_context *context,
|
|||
* ssl params which fail then retry
|
||||
* and succeed
|
||||
*/
|
||||
debug("SSL_accept failed skt %u: %s\n",
|
||||
_debug("SSL_accept failed skt %u: %s\n",
|
||||
pollfd->fd,
|
||||
ERR_error_string(SSL_get_error(
|
||||
new_wsi->ssl, n), NULL));
|
||||
|
@ -1630,14 +1630,14 @@ libwebsocket_service_fd(struct libwebsocket_context *context,
|
|||
break;
|
||||
}
|
||||
|
||||
debug("accepted new SSL conn "
|
||||
_debug("accepted new SSL conn "
|
||||
"port %u on fd=%d SSL ver %s\n",
|
||||
ntohs(cli_addr.sin_port), accept_fd,
|
||||
SSL_get_version(new_wsi->ssl));
|
||||
|
||||
} else
|
||||
#endif
|
||||
debug("accepted new conn port %u on fd=%d\n",
|
||||
_debug("accepted new conn port %u on fd=%d\n",
|
||||
ntohs(cli_addr.sin_port), accept_fd);
|
||||
|
||||
insert_wsi(context, new_wsi);
|
||||
|
@ -1689,8 +1689,8 @@ libwebsocket_service_fd(struct libwebsocket_context *context,
|
|||
|
||||
/* create a dummy wsi for the connection and add it */
|
||||
|
||||
new_wsi = malloc(sizeof(struct libwebsocket));
|
||||
memset(new_wsi, 0, sizeof(struct libwebsocket));
|
||||
new_wsi = (struct libwebsocket *)malloc(sizeof(struct libwebsocket));
|
||||
memset(new_wsi, 0, sizeof (struct libwebsocket));
|
||||
new_wsi->sock = accept_fd;
|
||||
new_wsi->mode = LWS_CONNMODE_BROADCAST_PROXY;
|
||||
new_wsi->state = WSI_STATE_ESTABLISHED;
|
||||
|
@ -1719,7 +1719,7 @@ libwebsocket_service_fd(struct libwebsocket_context *context,
|
|||
|
||||
if (pollfd->revents & (POLLERR | POLLHUP)) {
|
||||
|
||||
debug("Session Socket %p (fd=%d) dead\n",
|
||||
_debug("Session Socket %p (fd=%d) dead\n",
|
||||
(void *)wsi, pollfd->fd);
|
||||
|
||||
libwebsocket_close_and_free_session(context, wsi,
|
||||
|
@ -2132,7 +2132,7 @@ libwebsocket_context_destroy(struct libwebsocket_context *context)
|
|||
if (context->listen_port)
|
||||
m = LWS_EXT_CALLBACK_SERVER_CONTEXT_DESTRUCT;
|
||||
while (ext && ext->callback) {
|
||||
ext->callback(context, ext, NULL, m, NULL, NULL, 0);
|
||||
ext->callback(context, ext, NULL, (enum libwebsocket_extension_callback_reasons)m, NULL, NULL, 0);
|
||||
ext++;
|
||||
}
|
||||
|
||||
|
@ -2603,7 +2603,7 @@ libwebsocket_create_context(int port, const char *interf,
|
|||
#endif
|
||||
|
||||
|
||||
context = malloc(sizeof(struct libwebsocket_context));
|
||||
context = (struct libwebsocket_context *) malloc(sizeof(struct libwebsocket_context));
|
||||
if (!context) {
|
||||
fprintf(stderr, "No memory for websocket context\n");
|
||||
return NULL;
|
||||
|
@ -2909,8 +2909,8 @@ libwebsocket_create_context(int port, const char *interf,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
wsi = malloc(sizeof(struct libwebsocket));
|
||||
memset(wsi, 0, sizeof(struct libwebsocket));
|
||||
wsi = (struct libwebsocket *)malloc(sizeof(struct libwebsocket));
|
||||
memset(wsi, 0, sizeof (struct libwebsocket));
|
||||
wsi->sock = sockfd;
|
||||
wsi->count_active_extensions = 0;
|
||||
wsi->mode = LWS_CONNMODE_SERVER_LISTENER;
|
||||
|
@ -2952,7 +2952,7 @@ libwebsocket_create_context(int port, const char *interf,
|
|||
protocols[context->count_protocols].callback;
|
||||
context->count_protocols++) {
|
||||
|
||||
debug(" Protocol: %s\n", protocols[context->count_protocols].name);
|
||||
_debug(" Protocol: %s\n", protocols[context->count_protocols].name);
|
||||
|
||||
protocols[context->count_protocols].owning_server = context;
|
||||
protocols[context->count_protocols].protocol_index =
|
||||
|
@ -2990,14 +2990,14 @@ libwebsocket_create_context(int port, const char *interf,
|
|||
ntohs(cli_addr.sin_port);
|
||||
listen(fd, 5);
|
||||
|
||||
debug(" Protocol %s broadcast socket %d\n",
|
||||
_debug(" Protocol %s broadcast socket %d\n",
|
||||
protocols[context->count_protocols].name,
|
||||
ntohs(cli_addr.sin_port));
|
||||
|
||||
/* dummy wsi per broadcast proxy socket */
|
||||
|
||||
wsi = malloc(sizeof(struct libwebsocket));
|
||||
memset(wsi, 0, sizeof(struct libwebsocket));
|
||||
wsi = (struct libwebsocket *)malloc(sizeof(struct libwebsocket));
|
||||
memset(wsi, 0, sizeof (struct libwebsocket));
|
||||
wsi->sock = fd;
|
||||
wsi->mode = LWS_CONNMODE_BROADCAST_PROXY_LISTENER;
|
||||
wsi->count_active_extensions = 0;
|
||||
|
@ -3031,8 +3031,9 @@ libwebsocket_create_context(int port, const char *interf,
|
|||
if (extensions) {
|
||||
while (extensions->callback) {
|
||||
debug(" Extension: %s\n", extensions->name);
|
||||
extensions->callback(context, extensions,
|
||||
NULL, m, NULL, NULL, 0);
|
||||
extensions->callback(context, extensions, NULL,
|
||||
(enum libwebsocket_extension_callback_reasons)m,
|
||||
NULL, NULL, 0);
|
||||
extensions++;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -77,7 +77,7 @@ int libwebsocket_parse(struct libwebsocket *wsi, unsigned char c)
|
|||
case WSI_TOKEN_HTTP:
|
||||
case WSI_TOKEN_MUXURL:
|
||||
|
||||
debug("WSI_TOKEN_(%d) '%c'\n", wsi->parser_state, c);
|
||||
_debug("WSI_TOKEN_(%d) '%c'\n", wsi->parser_state, c);
|
||||
|
||||
/* collect into malloc'd buffers */
|
||||
/* optional space swallow */
|
||||
|
@ -105,7 +105,7 @@ int libwebsocket_parse(struct libwebsocket *wsi, unsigned char c)
|
|||
wsi->parser_state = WSI_TOKEN_SKIPPING;
|
||||
break;
|
||||
}
|
||||
wsi->utf8_token[wsi->parser_state].token =
|
||||
wsi->utf8_token[wsi->parser_state].token = (char *)
|
||||
realloc(wsi->utf8_token[wsi->parser_state].token,
|
||||
wsi->current_alloc_len);
|
||||
}
|
||||
|
@ -115,7 +115,7 @@ int libwebsocket_parse(struct libwebsocket *wsi, unsigned char c)
|
|||
wsi->utf8_token[wsi->parser_state].token[
|
||||
wsi->utf8_token[wsi->parser_state].token_len] = '\0';
|
||||
wsi->parser_state = WSI_TOKEN_SKIPPING_SAW_CR;
|
||||
debug("*\n");
|
||||
_debug("*\n");
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -156,7 +156,7 @@ int libwebsocket_parse(struct libwebsocket *wsi, unsigned char c)
|
|||
|
||||
/* For any supported protocol we have enough payload */
|
||||
|
||||
debug("Setting WSI_PARSING_COMPLETE\n");
|
||||
_debug("Setting WSI_PARSING_COMPLETE\n");
|
||||
wsi->parser_state = WSI_PARSING_COMPLETE;
|
||||
break;
|
||||
|
||||
|
@ -164,14 +164,14 @@ int libwebsocket_parse(struct libwebsocket *wsi, unsigned char c)
|
|||
wsi->parser_state = WSI_TOKEN_MUXURL;
|
||||
wsi->current_alloc_len = LWS_INITIAL_HDR_ALLOC;
|
||||
|
||||
wsi->utf8_token[wsi->parser_state].token =
|
||||
wsi->utf8_token[wsi->parser_state].token = (char *)
|
||||
malloc(wsi->current_alloc_len);
|
||||
wsi->utf8_token[wsi->parser_state].token_len = 0;
|
||||
break;
|
||||
|
||||
/* collecting and checking a name part */
|
||||
case WSI_TOKEN_NAME_PART:
|
||||
debug("WSI_TOKEN_NAME_PART '%c'\n", c);
|
||||
_debug("WSI_TOKEN_NAME_PART '%c'\n", c);
|
||||
|
||||
if (wsi->name_buffer_pos == sizeof(wsi->name_buffer) - 1) {
|
||||
/* name bigger than we can handle, skip until next */
|
||||
|
@ -186,7 +186,7 @@ int libwebsocket_parse(struct libwebsocket *wsi, unsigned char c)
|
|||
continue;
|
||||
if (strcasecmp(lws_tokens[n].token, wsi->name_buffer))
|
||||
continue;
|
||||
debug("known hdr '%s'\n", wsi->name_buffer);
|
||||
_debug("known hdr '%s'\n", wsi->name_buffer);
|
||||
|
||||
/*
|
||||
* WSORIGIN is protocol equiv to ORIGIN,
|
||||
|
@ -195,7 +195,7 @@ int libwebsocket_parse(struct libwebsocket *wsi, unsigned char c)
|
|||
if (n == WSI_TOKEN_SWORIGIN)
|
||||
n = WSI_TOKEN_ORIGIN;
|
||||
|
||||
wsi->parser_state = WSI_TOKEN_GET_URI + n;
|
||||
wsi->parser_state = (enum lws_token_indexes) (WSI_TOKEN_GET_URI + n);
|
||||
|
||||
n = WSI_TOKEN_COUNT;
|
||||
|
||||
|
@ -204,7 +204,7 @@ int libwebsocket_parse(struct libwebsocket *wsi, unsigned char c)
|
|||
continue;
|
||||
|
||||
wsi->current_alloc_len = LWS_INITIAL_HDR_ALLOC;
|
||||
wsi->utf8_token[wsi->parser_state].token =
|
||||
wsi->utf8_token[wsi->parser_state].token = (char *)
|
||||
malloc(wsi->current_alloc_len);
|
||||
wsi->utf8_token[wsi->parser_state].token_len = 0;
|
||||
}
|
||||
|
@ -226,7 +226,7 @@ int libwebsocket_parse(struct libwebsocket *wsi, unsigned char c)
|
|||
wsi->parser_state = WSI_TOKEN_GET_URI;
|
||||
wsi->current_alloc_len = LWS_INITIAL_HDR_ALLOC;
|
||||
wsi->utf8_token[WSI_TOKEN_GET_URI].token =
|
||||
malloc(wsi->current_alloc_len);
|
||||
(char *)malloc(wsi->current_alloc_len);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -238,7 +238,7 @@ int libwebsocket_parse(struct libwebsocket *wsi, unsigned char c)
|
|||
|
||||
if (!wsi->utf8_token[WSI_TOKEN_UPGRADE].token_len) {
|
||||
/* they're HTTP headers, not websocket upgrade! */
|
||||
debug("Setting WSI_PARSING_COMPLETE "
|
||||
_debug("Setting WSI_PARSING_COMPLETE "
|
||||
"from http headers\n");
|
||||
wsi->parser_state = WSI_PARSING_COMPLETE;
|
||||
}
|
||||
|
@ -247,7 +247,7 @@ int libwebsocket_parse(struct libwebsocket *wsi, unsigned char c)
|
|||
|
||||
if (wsi->utf8_token[WSI_TOKEN_VERSION].token_len &&
|
||||
atoi(wsi->utf8_token[WSI_TOKEN_VERSION].token) >= 4) {
|
||||
debug("04 header completed\n");
|
||||
_debug("04 header completed\n");
|
||||
wsi->parser_state = WSI_PARSING_COMPLETE;
|
||||
wsi->utf8_token[WSI_TOKEN_CHALLENGE].token_len = 0;
|
||||
free(wsi->utf8_token[WSI_TOKEN_CHALLENGE].token);
|
||||
|
@ -257,7 +257,7 @@ int libwebsocket_parse(struct libwebsocket *wsi, unsigned char c)
|
|||
/* client parser? */
|
||||
|
||||
if (wsi->ietf_spec_revision >= 4) {
|
||||
debug("04 header completed\n");
|
||||
_debug("04 header completed\n");
|
||||
wsi->parser_state = WSI_PARSING_COMPLETE;
|
||||
}
|
||||
|
||||
|
@ -265,12 +265,12 @@ int libwebsocket_parse(struct libwebsocket *wsi, unsigned char c)
|
|||
|
||||
/* skipping arg part of a name we didn't recognize */
|
||||
case WSI_TOKEN_SKIPPING:
|
||||
debug("WSI_TOKEN_SKIPPING '%c'\n", c);
|
||||
_debug("WSI_TOKEN_SKIPPING '%c'\n", c);
|
||||
if (c == '\x0d')
|
||||
wsi->parser_state = WSI_TOKEN_SKIPPING_SAW_CR;
|
||||
break;
|
||||
case WSI_TOKEN_SKIPPING_SAW_CR:
|
||||
debug("WSI_TOKEN_SKIPPING_SAW_CR '%c'\n", c);
|
||||
_debug("WSI_TOKEN_SKIPPING_SAW_CR '%c'\n", c);
|
||||
if (c == '\x0a')
|
||||
wsi->parser_state = WSI_TOKEN_NAME_PART;
|
||||
else
|
||||
|
@ -279,7 +279,7 @@ int libwebsocket_parse(struct libwebsocket *wsi, unsigned char c)
|
|||
break;
|
||||
/* we're done, ignore anything else */
|
||||
case WSI_PARSING_COMPLETE:
|
||||
debug("WSI_PARSING_COMPLETE '%c'\n", c);
|
||||
_debug("WSI_PARSING_COMPLETE '%c'\n", c);
|
||||
break;
|
||||
|
||||
default: /* keep gcc happy */
|
||||
|
@ -671,7 +671,7 @@ issue:
|
|||
if (c)
|
||||
break;
|
||||
|
||||
debug("Seen that client is requesting "
|
||||
_debug("Seen that client is requesting "
|
||||
"a v76 close, sending ack\n");
|
||||
buf[0] = 0xff;
|
||||
buf[1] = 0;
|
||||
|
@ -680,7 +680,7 @@ issue:
|
|||
fprintf(stderr, "ERROR writing to socket");
|
||||
return -1;
|
||||
}
|
||||
debug(" v76 close ack sent, server closing skt\n");
|
||||
_debug(" v76 close ack sent, server closing skt\n");
|
||||
/* returning < 0 will get it closed in parent */
|
||||
return -1;
|
||||
|
||||
|
@ -741,7 +741,7 @@ spill:
|
|||
* layer? If so service it and hide it from the user callback
|
||||
*/
|
||||
|
||||
debug("spill on %s\n", wsi->protocol->name);
|
||||
_debug("spill on %s\n", wsi->protocol->name);
|
||||
|
||||
switch (wsi->opcode) {
|
||||
case LWS_WS_OPCODE_07__CLOSE:
|
||||
|
@ -751,7 +751,7 @@ spill:
|
|||
* fine he has told us he is closing too, let's
|
||||
* finish our close
|
||||
*/
|
||||
debug("seen client close ack\n");
|
||||
_debug("seen client close ack\n");
|
||||
return -1;
|
||||
}
|
||||
debug("server sees client close packet\n");
|
||||
|
@ -786,7 +786,7 @@ spill:
|
|||
|
||||
default:
|
||||
|
||||
debug("passing opcode %x up to exts\n", wsi->opcode);
|
||||
_debug("passing opcode %x up to exts\n", wsi->opcode);
|
||||
|
||||
/*
|
||||
* It's something special we can't understand here.
|
||||
|
@ -880,7 +880,7 @@ int libwebsocket_client_rx_sm(struct libwebsocket *wsi, unsigned char c)
|
|||
struct lws_tokens eff_buf;
|
||||
int m;
|
||||
|
||||
debug(" CRX: %02X %d\n", c, wsi->lws_rx_parse_state);
|
||||
_debug(" CRX: %02X %d\n", c, wsi->lws_rx_parse_state);
|
||||
|
||||
switch (wsi->lws_rx_parse_state) {
|
||||
case LWS_RXPS_NEW:
|
||||
|
@ -1186,7 +1186,7 @@ issue:
|
|||
if (c)
|
||||
break;
|
||||
|
||||
debug("Seen that client is requesting "
|
||||
_debug("Seen that client is requesting "
|
||||
"a v76 close, sending ack\n");
|
||||
buf[0] = 0xff;
|
||||
buf[1] = 0;
|
||||
|
@ -1195,7 +1195,7 @@ issue:
|
|||
fprintf(stderr, "ERROR writing to socket");
|
||||
return -1;
|
||||
}
|
||||
debug(" v76 close ack sent, server closing skt\n");
|
||||
_debug(" v76 close ack sent, server closing skt\n");
|
||||
/* returning < 0 will get it closed in parent */
|
||||
return -1;
|
||||
|
||||
|
@ -1237,12 +1237,12 @@ spill:
|
|||
debug("seen server's close ack\n");
|
||||
return -1;
|
||||
}
|
||||
debug("client sees server close packet len = %d\n", wsi->rx_user_buffer_head);
|
||||
_debug("client sees server close packet len = %d\n", wsi->rx_user_buffer_head);
|
||||
/* parrot the close packet payload back */
|
||||
n = libwebsocket_write(wsi, (unsigned char *)
|
||||
&wsi->rx_user_buffer[LWS_SEND_BUFFER_PRE_PADDING],
|
||||
wsi->rx_user_buffer_head, LWS_WRITE_CLOSE);
|
||||
debug("client writing close ack returned %d\n", n);
|
||||
_debug("client writing close ack returned %d\n", n);
|
||||
wsi->state = WSI_STATE_RETURNED_CLOSE_ALREADY;
|
||||
/* close the connection */
|
||||
return -1;
|
||||
|
@ -1336,7 +1336,8 @@ spill:
|
|||
if (wsi->protocol->callback)
|
||||
wsi->protocol->callback(
|
||||
wsi->protocol->owning_server,
|
||||
wsi, callback_action,
|
||||
wsi,
|
||||
(enum libwebsocket_callback_reasons)callback_action,
|
||||
wsi->user_space,
|
||||
eff_buf.token,
|
||||
eff_buf.token_len);
|
||||
|
@ -1573,7 +1574,7 @@ lws_issue_raw_ext_access(struct libwebsocket *wsi,
|
|||
eff_buf.token_len))
|
||||
return -1;
|
||||
|
||||
debug("written %d bytes to client\n", eff_buf.token_len);
|
||||
_debug("written %d bytes to client\n", eff_buf.token_len);
|
||||
|
||||
/* no extension has more to spill */
|
||||
|
||||
|
|
|
@ -82,12 +82,12 @@
|
|||
#include "libwebsockets.h"
|
||||
|
||||
#if 0
|
||||
#define DEBUG
|
||||
#define _DEBUG
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG
|
||||
#ifdef _DEBUG
|
||||
#ifdef WIN32
|
||||
static
|
||||
#define _debug(...) lws_log(LWS_LOG_DEBUG, __VA_ARGS__)
|
||||
#else
|
||||
static inline
|
||||
#endif
|
||||
|
@ -98,10 +98,10 @@ void debug(const char *format, ...)
|
|||
}
|
||||
#else
|
||||
#ifdef WIN32
|
||||
#define debug(...)
|
||||
#define _debug(...)
|
||||
#else
|
||||
static inline
|
||||
void debug(const char *format, ...)
|
||||
void _debug(const char *format, ...)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Add table
Reference in a new issue