[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[libmicrohttpd] 04/05: websockets: fixed code style
From: |
gnunet |
Subject: |
[libmicrohttpd] 04/05: websockets: fixed code style |
Date: |
Sun, 31 Oct 2021 14:37:34 +0100 |
This is an automated email from the git hooks/post-receive script.
karlson2k pushed a commit to branch master
in repository libmicrohttpd.
commit f44e4bf89644579cfc203db77336a2a2b0e19da0
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
AuthorDate: Sun Oct 31 16:34:05 2021 +0300
websockets: fixed code style
---
doc/examples/websocket.c | 39 +--
src/examples/websocket_chatserver_example.c | 121 ++++-----
src/examples/websocket_threaded_example.c | 4 +-
src/include/microhttpd_ws.h | 106 ++++----
src/microhttpd_ws/mhd_websocket.c | 373 ++++++++++++++--------------
src/microhttpd_ws/sha1.c | 2 +-
src/microhttpd_ws/test_websocket.c | 295 +++++++++++-----------
src/microhttpd_ws/test_websocket_browser.c | 71 +++---
8 files changed, 516 insertions(+), 495 deletions(-)
diff --git a/doc/examples/websocket.c b/doc/examples/websocket.c
index 39995479..fad1e95f 100644
--- a/doc/examples/websocket.c
+++ b/doc/examples/websocket.c
@@ -73,6 +73,7 @@ static void
send_all (MHD_socket fd,
const char *buf,
size_t len);
+
static void
make_blocking (MHD_socket fd);
@@ -89,7 +90,7 @@ upgrade_handler (void *cls,
make_blocking (fd);
/* create a websocket stream for this connection */
- struct MHD_WebSocketStream* ws;
+ struct MHD_WebSocketStream *ws;
int result = MHD_websocket_stream_init (&ws,
0,
0);
@@ -241,6 +242,7 @@ upgrade_handler (void *cls,
MHD_UPGRADE_ACTION_CLOSE);
}
+
/* This helper function is used for the case that
* we need to resend some data
*/
@@ -272,6 +274,7 @@ send_all (MHD_socket fd,
}
}
+
/* This helper function contains operating-system-dependent code and
* is used to make a socket blocking.
*/
@@ -294,6 +297,7 @@ make_blocking (MHD_socket fd)
#endif
}
+
static enum MHD_Result
access_handler (void *cls,
struct MHD_Connection *connection,
@@ -326,9 +330,9 @@ access_handler (void *cls,
{
/* Default page for visiting the server */
struct MHD_Response *response = MHD_create_response_from_buffer (
- strlen (PAGE),
- PAGE,
- MHD_RESPMEM_PERSISTENT);
+ strlen (PAGE),
+ PAGE,
+ MHD_RESPMEM_PERSISTENT);
ret = MHD_queue_response (connection,
MHD_HTTP_OK,
response);
@@ -337,7 +341,7 @@ access_handler (void *cls,
else if (0 == strcmp (url, "/chat"))
{
char is_valid = 1;
- const char* value = NULL;
+ const char *value = NULL;
char sec_websocket_accept[29];
if (0 != MHD_websocket_check_http_version (version))
@@ -395,10 +399,10 @@ access_handler (void *cls,
else
{
/* return error page */
- struct MHD_Response*response = MHD_create_response_from_buffer (
- strlen (PAGE_INVALID_WEBSOCKET_REQUEST),
- PAGE_INVALID_WEBSOCKET_REQUEST,
- MHD_RESPMEM_PERSISTENT);
+ struct MHD_Response *response = MHD_create_response_from_buffer (
+ strlen (PAGE_INVALID_WEBSOCKET_REQUEST),
+ PAGE_INVALID_WEBSOCKET_REQUEST,
+ MHD_RESPMEM_PERSISTENT);
ret = MHD_queue_response (connection,
MHD_HTTP_BAD_REQUEST,
response);
@@ -407,10 +411,10 @@ access_handler (void *cls,
}
else
{
- struct MHD_Response*response = MHD_create_response_from_buffer (
- strlen (PAGE_NOT_FOUND),
- PAGE_NOT_FOUND,
- MHD_RESPMEM_PERSISTENT);
+ struct MHD_Response *response = MHD_create_response_from_buffer (
+ strlen (PAGE_NOT_FOUND),
+ PAGE_NOT_FOUND,
+ MHD_RESPMEM_PERSISTENT);
ret = MHD_queue_response (connection,
MHD_HTTP_NOT_FOUND,
response);
@@ -420,6 +424,7 @@ access_handler (void *cls,
return ret;
}
+
int
main (int argc,
char *const *argv)
@@ -428,10 +433,10 @@ main (int argc,
(void) argv; /* Unused. Silent compiler warning. */
struct MHD_Daemon *daemon;
- daemon = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD |
- MHD_USE_THREAD_PER_CONNECTION |
- MHD_ALLOW_UPGRADE |
- MHD_USE_ERROR_LOG,
+ daemon = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD
+ | MHD_USE_THREAD_PER_CONNECTION
+ | MHD_ALLOW_UPGRADE
+ | MHD_USE_ERROR_LOG,
PORT, NULL, NULL,
&access_handler, NULL,
MHD_OPTION_END);
diff --git a/src/examples/websocket_chatserver_example.c
b/src/examples/websocket_chatserver_example.c
index 0893279b..eb5dad39 100644
--- a/src/examples/websocket_chatserver_example.c
+++ b/src/examples/websocket_chatserver_example.c
@@ -629,14 +629,14 @@ struct ConnectedUser
/* the UpgradeResponseHandle of libmicrohttpd (needed for closing the
socket) */
struct MHD_UpgradeResponseHandle *urh;
/* the websocket encode/decode stream */
- struct MHD_WebSocketStream*ws;
+ struct MHD_WebSocketStream *ws;
/* the possibly read data at the start (only used once) */
char *extra_in;
size_t extra_in_size;
/* the unique user id (counting from 1, ids will never be re-used) */
size_t user_id;
/* the current user name */
- char*user_name;
+ char *user_name;
size_t user_name_len;
/* the zero-based index of the next message;
may be decremented when old messages are deleted */
@@ -673,7 +673,7 @@ struct Message
/* The user id of the recipient. This is 0 if every connected user shall
receive it */
size_t to_user_id;
/* The data of the message. */
- char*data;
+ char *data;
size_t data_len;
/* Specifies whether the data is UTF-8 encoded text (0) or binary data (1) */
int is_binary;
@@ -684,9 +684,9 @@ size_t unique_user_id = 0;
/* the chat data (users and messages; may be accessed by all threads, but is
protected by mutex) */
pthread_mutex_t chat_mutex;
-struct ConnectedUser**users = NULL;
+struct ConnectedUser **users = NULL;
size_t user_count = 0;
-struct Message**messages = NULL;
+struct Message **messages = NULL;
size_t message_count = 0;
/* specifies whether all websockets must close (1) or not (0) */
volatile int disconnect_all = 0;
@@ -728,7 +728,7 @@ make_blocking (MHD_socket fd)
* @param len The length in bytes of the data in the buffer
*/
static void
-send_all (struct ConnectedUser*cu,
+send_all (struct ConnectedUser *cu,
const char *buf,
size_t len)
{
@@ -776,13 +776,13 @@ send_all (struct ConnectedUser*cu,
static int
chat_addmessage (size_t from_user_id,
size_t to_user_id,
- char*data,
+ char *data,
size_t data_len,
int is_binary,
int needs_lock)
{
/* allocate the buffer and fill it with data */
- struct Message*message = (struct Message*) malloc (sizeof (struct Message));
+ struct Message *message = (struct Message *) malloc (sizeof (struct
Message));
if (NULL == message)
return 1;
@@ -809,10 +809,10 @@ chat_addmessage (size_t from_user_id,
/* add the new message to the global message list */
size_t message_count_ = message_count + 1;
- struct Message**messages_ = (struct Message**) realloc (messages,
- message_count_
- * sizeof (struct
- Message*));
+ struct Message **messages_ = (struct Message **) realloc (messages,
+ message_count_
+ * sizeof (struct
+ Message
*));
if (NULL == messages_)
{
free (message);
@@ -928,14 +928,14 @@ chat_clearmessages (int needs_lock)
* @return 0 on success, other values on error
*/
static int
-chat_adduser (struct ConnectedUser*cu)
+chat_adduser (struct ConnectedUser *cu)
{
/* initialize the notification message of the new user */
char user_index[32];
snprintf (user_index, 32, "%d", (int) cu->user_id);
size_t user_index_len = strlen (user_index);
size_t data_len = user_index_len + cu->user_name_len + 9;
- char*data = (char*) malloc (data_len + 1);
+ char *data = (char *) malloc (data_len + 1);
if (NULL == data)
return 1;
strcpy (data, "useradd|");
@@ -965,12 +965,12 @@ chat_adduser (struct ConnectedUser*cu)
/* add the new user to the list */
size_t user_count_ = user_count + 1;
- struct ConnectedUser**users_ = (struct ConnectedUser**) realloc (users,
- user_count_
- * sizeof (
- struct
-
ConnectedUser
- *));
+ struct ConnectedUser **users_ = (struct ConnectedUser **) realloc (users,
+
user_count_
+ * sizeof (
+ struct
+
ConnectedUser
+ *));
if (NULL == users_)
{
/* realloc failed */
@@ -998,7 +998,7 @@ chat_adduser (struct ConnectedUser*cu)
* @return 0 on success, other values on error
*/
static int
-chat_removeuser (struct ConnectedUser*cu)
+chat_removeuser (struct ConnectedUser *cu)
{
char user_index[32];
@@ -1006,7 +1006,7 @@ chat_removeuser (struct ConnectedUser*cu)
snprintf (user_index, 32, "%d", (int) cu->user_id);
size_t user_index_len = strlen (user_index);
size_t data_len = user_index_len + 9;
- char*data = (char*) malloc (data_len + 1);
+ char *data = (char *) malloc (data_len + 1);
if (NULL == data)
return 1;
strcpy (data, "userdel|");
@@ -1061,8 +1061,8 @@ chat_removeuser (struct ConnectedUser*cu)
* @return 0 on success, other values on error. 2 means name
already in use.
*/
static int
-chat_renameuser (struct ConnectedUser*cu,
- char*new_name,
+chat_renameuser (struct ConnectedUser *cu,
+ char *new_name,
size_t new_name_len)
{
/* lock the mutex */
@@ -1090,7 +1090,7 @@ chat_renameuser (struct ConnectedUser*cu,
snprintf (user_index, 32, "%d", (int) cu->user_id);
size_t user_index_len = strlen (user_index);
size_t data_len = user_index_len + new_name_len + 10;
- char*data = (char*) malloc (data_len + 1);
+ char *data = (char *) malloc (data_len + 1);
if (NULL == data)
return 1;
strcpy (data, "username|");
@@ -1128,8 +1128,8 @@ chat_renameuser (struct ConnectedUser*cu,
* @return 0 on success, other values on error
*/
static int
-connecteduser_parse_received_websocket_stream (struct ConnectedUser*cu,
- char*buf,
+connecteduser_parse_received_websocket_stream (struct ConnectedUser *cu,
+ char *buf,
size_t buf_len)
{
size_t buf_offset = 0;
@@ -1270,7 +1270,7 @@ connecteduser_parse_received_websocket_stream (struct
ConnectedUser*cu,
snprintf (user_index, 32, "%d", (int) cu->user_id);
size_t user_index_len = strlen (user_index);
size_t data_len = user_index_len + frame_len - j + 9;
- char*data = (char*) malloc (data_len + 1);
+ char *data = (char *) malloc (data_len + 1);
if (NULL != data)
{
strcpy (data, "regular|");
@@ -1307,7 +1307,7 @@ connecteduser_parse_received_websocket_stream (struct
ConnectedUser*cu,
snprintf (user_index, 32, "%d", (int) cu->user_id);
size_t user_index_len = strlen (user_index);
size_t data_len = user_index_len + frame_len - j + 9;
- char*data = (char*) malloc (data_len + 1);
+ char *data = (char *) malloc (data_len + 1);
if (NULL != data)
{
@@ -1347,7 +1347,7 @@ connecteduser_parse_received_websocket_stream (struct
ConnectedUser*cu,
1);
break;
}
- char*new_name = (char*) malloc (new_name_len + 1);
+ char *new_name = (char *) malloc (new_name_len + 1);
if (NULL == new_name)
{
chat_addmessage (0,
@@ -1415,7 +1415,7 @@ connecteduser_parse_received_websocket_stream (struct
ConnectedUser*cu,
if (0 == pthread_mutex_lock (&chat_mutex))
{
/* check whether the to_user exists */
- struct ConnectedUser*ping_user = NULL;
+ struct ConnectedUser *ping_user = NULL;
for (size_t k = 0; k < user_count; ++k)
{
if (users[k]->user_id == to_user_id)
@@ -1478,7 +1478,7 @@ connecteduser_parse_received_websocket_stream (struct
ConnectedUser*cu,
MHD_websocket_free (cu->ws,
frame_data);
{
- char*result = NULL;
+ char *result = NULL;
size_t result_len = 0;
int er = MHD_websocket_encode_close (cu->ws,
MHD_WEBSOCKET_CLOSEREASON_REGULAR,
@@ -1545,7 +1545,8 @@ connecteduser_parse_received_websocket_stream (struct
ConnectedUser*cu,
snprintf (result_text + 5, 235, "%d", (int) cu->user_id);
strcat (result_text,
"|");
- snprintf (result_text + strlen (result_text), 240 - strlen
(result_text), "%d", (int) ping);
+ snprintf (result_text + strlen (result_text), 240 - strlen (
+ result_text), "%d", (int) ping);
chat_addmessage (0,
0,
result_text,
@@ -1586,7 +1587,7 @@ connecteduser_parse_received_websocket_stream (struct
ConnectedUser*cu,
* @return Always NULL
*/
static void *
-connecteduser_send_messages (void*cls)
+connecteduser_send_messages (void *cls)
{
struct ConnectedUser *cu = cls;
@@ -1602,7 +1603,7 @@ connecteduser_send_messages (void*cls)
if (1 == disconnect_all)
{
/* the application closes and want that we disconnect all users */
- struct MHD_UpgradeResponseHandle*urh = cu->urh;
+ struct MHD_UpgradeResponseHandle *urh = cu->urh;
if (NULL != urh)
{
/* Close the TCP/IP socket. */
@@ -1629,7 +1630,7 @@ connecteduser_send_messages (void*cls)
"libmicrohttpdchatserverpingdata");
snprintf (cu->ping_message + 31, 97, "%d", (int) cu->ping_counter);
cu->ping_message_len = strlen (cu->ping_message);
- char*frame_data = NULL;
+ char *frame_data = NULL;
size_t frame_len = 0;
int er = MHD_websocket_encode_ping (cu->ws,
cu->ping_message,
@@ -1657,11 +1658,11 @@ connecteduser_send_messages (void*cls)
else if (cu->next_message_index < message_count)
{
/* a chat message or command is pending */
- char*frame_data = NULL;
+ char *frame_data = NULL;
size_t frame_len = 0;
int er = 0;
{
- struct Message*msg = messages[cu->next_message_index];
+ struct Message *msg = messages[cu->next_message_index];
if ((0 == msg->to_user_id) ||
(cu->user_id == msg->to_user_id) ||
(cu->user_id == msg->from_user_id) )
@@ -1810,10 +1811,10 @@ connecteduser_receive_messages (void *cls)
{
struct UserInit
{
- char*user_init;
+ char *user_init;
size_t user_init_len;
};
- struct UserInit*init_users = NULL;
+ struct UserInit *init_users = NULL;
size_t init_users_len = 0;
/* first collect all users without sending (so the mutex isn't locked too
long) */
@@ -1821,8 +1822,8 @@ connecteduser_receive_messages (void *cls)
{
if (0 < user_count)
{
- init_users = (struct UserInit*) malloc (user_count * sizeof (struct
-
UserInit));
+ init_users = (struct UserInit *) malloc (user_count * sizeof (struct
+
UserInit));
if (NULL != init_users)
{
init_users_len = user_count;
@@ -1833,7 +1834,7 @@ connecteduser_receive_messages (void *cls)
size_t user_index_len = strlen (user_index);
struct UserInit iu;
iu.user_init_len = user_index_len + users[i]->user_name_len + 10;
- iu.user_init = (char*) malloc (iu.user_init_len + 1);
+ iu.user_init = (char *) malloc (iu.user_init_len + 1);
if (NULL != iu.user_init)
{
strcpy (iu.user_init, "userinit|");
@@ -1929,7 +1930,7 @@ connecteduser_receive_messages (void *cls)
pthread_mutex_unlock (&chat_mutex);
pthread_join (pt, NULL);
}
- struct MHD_UpgradeResponseHandle*urh = cu->urh;
+ struct MHD_UpgradeResponseHandle *urh = cu->urh;
if (NULL != urh)
{
cu->urh = NULL;
@@ -1974,7 +1975,7 @@ connecteduser_receive_messages (void *cls)
pthread_mutex_unlock (&chat_mutex);
pthread_join (pt, NULL);
}
- struct MHD_UpgradeResponseHandle*urh = cu->urh;
+ struct MHD_UpgradeResponseHandle *urh = cu->urh;
if (NULL != urh)
{
cu->urh = NULL;
@@ -2000,7 +2001,7 @@ connecteduser_receive_messages (void *cls)
pthread_mutex_unlock (&chat_mutex);
pthread_join (pt, NULL);
}
- struct MHD_UpgradeResponseHandle*urh = cu->urh;
+ struct MHD_UpgradeResponseHandle *urh = cu->urh;
if (NULL != urh)
{
cu->urh = NULL;
@@ -2161,10 +2162,10 @@ access_handler (void *cls,
if (0 == strcmp (url, "/"))
{
/* Default page for visiting the server */
- struct MHD_Response*response = MHD_create_response_from_buffer (strlen (
- PAGE),
- PAGE,
-
MHD_RESPMEM_PERSISTENT);
+ struct MHD_Response *response = MHD_create_response_from_buffer (strlen (
+ PAGE),
+ PAGE,
+
MHD_RESPMEM_PERSISTENT);
ret = MHD_queue_response (connection,
MHD_HTTP_OK,
response);
@@ -2188,7 +2189,7 @@ access_handler (void *cls,
*/
char is_valid = 1;
- const char* value = NULL;
+ const char *value = NULL;
char sec_websocket_accept[29];
/* check whether an websocket upgrade is requested */
@@ -2257,10 +2258,10 @@ access_handler (void *cls,
else
{
/* return error page */
- struct MHD_Response*response = MHD_create_response_from_buffer (strlen (
-
PAGE_INVALID_WEBSOCKET_REQUEST),
-
PAGE_INVALID_WEBSOCKET_REQUEST,
-
MHD_RESPMEM_PERSISTENT);
+ struct MHD_Response *response = MHD_create_response_from_buffer (strlen (
+
PAGE_INVALID_WEBSOCKET_REQUEST),
+
PAGE_INVALID_WEBSOCKET_REQUEST,
+
MHD_RESPMEM_PERSISTENT);
ret = MHD_queue_response (connection,
MHD_HTTP_BAD_REQUEST,
response);
@@ -2269,10 +2270,10 @@ access_handler (void *cls,
}
else
{
- struct MHD_Response*response = MHD_create_response_from_buffer (strlen (
-
PAGE_NOT_FOUND),
-
PAGE_NOT_FOUND,
-
MHD_RESPMEM_PERSISTENT);
+ struct MHD_Response *response = MHD_create_response_from_buffer (strlen (
+
PAGE_NOT_FOUND),
+
PAGE_NOT_FOUND,
+
MHD_RESPMEM_PERSISTENT);
ret = MHD_queue_response (connection,
MHD_HTTP_NOT_FOUND,
response);
@@ -2338,7 +2339,7 @@ main (int argc,
{
for (size_t i = 0; i < user_count; ++i)
{
- struct MHD_UpgradeResponseHandle*urh = users[i]->urh;
+ struct MHD_UpgradeResponseHandle *urh = users[i]->urh;
if (NULL != urh)
{
users[i]->urh = NULL;
diff --git a/src/examples/websocket_threaded_example.c
b/src/examples/websocket_threaded_example.c
index e2a2c9c1..1a2e2877 100644
--- a/src/examples/websocket_threaded_example.c
+++ b/src/examples/websocket_threaded_example.c
@@ -539,7 +539,7 @@ send_all (MHD_socket sock, const unsigned char *buf, size_t
len)
for (off = 0; off < len; off += ret)
{
- ret = send (sock, (const void*) &buf[off], len - off, 0);
+ ret = send (sock, (const void *) &buf[off], len - off, 0);
if (0 > ret)
{
if (EAGAIN == errno)
@@ -705,7 +705,7 @@ run_usock (void *cls)
make_blocking (ws->sock);
while (1)
{
- got = recv (ws->sock, (void*) buf, sizeof (buf), 0);
+ got = recv (ws->sock, (void *) buf, sizeof (buf), 0);
if (0 >= got)
{
break;
diff --git a/src/include/microhttpd_ws.h b/src/include/microhttpd_ws.h
index f19c140d..8708bd6f 100644
--- a/src/include/microhttpd_ws.h
+++ b/src/include/microhttpd_ws.h
@@ -547,7 +547,7 @@ enum MHD_WEBSOCKET_VALIDITY
* @return allocated memory
* @ingroup websocket
*/
-typedef void*
+typedef void *
(*MHD_WebSocketMallocCallback) (size_t buf_len);
/**
* This callback function is used internally by many websocket
@@ -565,7 +565,7 @@ typedef void*
* @return reallocated memory
* @ingroup websocket
*/
-typedef void*
+typedef void *
(*MHD_WebSocketReallocCallback) (void *buf, size_t new_buf_len);
/**
* This callback function is used internally by many websocket
@@ -600,7 +600,7 @@ typedef void
* @ingroup websocket
*/
typedef size_t
-(*MHD_WebSocketRandomNumberGenerator) (void *cls, void* buf, size_t buf_len);
+(*MHD_WebSocketRandomNumberGenerator) (void *cls, void *buf, size_t buf_len);
/**
* Checks the HTTP version of the incoming request.
@@ -615,7 +615,7 @@ typedef size_t
* @ingroup websocket
*/
_MHD_EXTERN enum MHD_WEBSOCKET_STATUS
-MHD_websocket_check_http_version (const char* http_version);
+MHD_websocket_check_http_version (const char *http_version);
/**
* Checks the value of the 'Connection' HTTP request header.
@@ -634,7 +634,7 @@ MHD_websocket_check_http_version (const char* http_version);
* @ingroup websocket
*/
_MHD_EXTERN enum MHD_WEBSOCKET_STATUS
-MHD_websocket_check_connection_header (const char* connection_header);
+MHD_websocket_check_connection_header (const char *connection_header);
/**
* Checks the value of the 'Upgrade' HTTP request header.
@@ -653,7 +653,7 @@ MHD_websocket_check_connection_header (const char*
connection_header);
* @ingroup websocket
*/
_MHD_EXTERN enum MHD_WEBSOCKET_STATUS
-MHD_websocket_check_upgrade_header (const char* upgrade_header);
+MHD_websocket_check_upgrade_header (const char *upgrade_header);
/**
* Checks the value of the 'Sec-WebSocket-Version' HTTP request header.
@@ -673,7 +673,7 @@ MHD_websocket_check_upgrade_header (const char*
upgrade_header);
* @ingroup websocket
*/
_MHD_EXTERN enum MHD_WEBSOCKET_STATUS
-MHD_websocket_check_version_header (const char* version_header);
+MHD_websocket_check_version_header (const char *version_header);
/**
* Creates the response value for the 'Sec-WebSocket-Key' HTTP request header.
@@ -695,8 +695,8 @@ MHD_websocket_check_version_header (const char*
version_header);
* @ingroup websocket
*/
_MHD_EXTERN enum MHD_WEBSOCKET_STATUS
-MHD_websocket_create_accept_header (const char* sec_websocket_key,
- char* sec_websocket_accept);
+MHD_websocket_create_accept_header (const char *sec_websocket_key,
+ char *sec_websocket_accept);
/**
* Creates a new websocket stream, used for decoding/encoding.
@@ -711,7 +711,7 @@ MHD_websocket_create_accept_header (const char*
sec_websocket_key,
* @ingroup websocket
*/
_MHD_EXTERN enum MHD_WEBSOCKET_STATUS
-MHD_websocket_stream_init (struct MHD_WebSocketStream**ws,
+MHD_websocket_stream_init (struct MHD_WebSocketStream **ws,
int flags,
size_t max_payload_size);
@@ -746,13 +746,13 @@ MHD_websocket_stream_init (struct MHD_WebSocketStream**ws,
* @ingroup websocket
*/
_MHD_EXTERN enum MHD_WEBSOCKET_STATUS
-MHD_websocket_stream_init2 (struct MHD_WebSocketStream**ws,
+MHD_websocket_stream_init2 (struct MHD_WebSocketStream **ws,
int flags,
size_t max_payload_size,
MHD_WebSocketMallocCallback callback_malloc,
MHD_WebSocketReallocCallback callback_realloc,
MHD_WebSocketFreeCallback callback_free,
- void* cls_rng,
+ void *cls_rng,
MHD_WebSocketRandomNumberGenerator callback_rng);
/**
@@ -764,7 +764,7 @@ MHD_websocket_stream_init2 (struct MHD_WebSocketStream**ws,
* @ingroup websocket
*/
_MHD_EXTERN enum MHD_WEBSOCKET_STATUS
-MHD_websocket_stream_free (struct MHD_WebSocketStream*ws);
+MHD_websocket_stream_free (struct MHD_WebSocketStream *ws);
/**
* Invalidates a websocket stream.
@@ -777,7 +777,7 @@ MHD_websocket_stream_free (struct MHD_WebSocketStream*ws);
* @ingroup websocket
*/
_MHD_EXTERN enum MHD_WEBSOCKET_STATUS
-MHD_websocket_stream_invalidate (struct MHD_WebSocketStream*ws);
+MHD_websocket_stream_invalidate (struct MHD_WebSocketStream *ws);
/**
* Queries whether a websocket stream is valid.
@@ -789,7 +789,7 @@ MHD_websocket_stream_invalidate (struct
MHD_WebSocketStream*ws);
* @ingroup websocket
*/
_MHD_EXTERN enum MHD_WEBSOCKET_VALIDITY
-MHD_websocket_stream_is_valid (struct MHD_WebSocketStream*ws);
+MHD_websocket_stream_is_valid (struct MHD_WebSocketStream *ws);
/**
* Decodes a byte sequence for a websocket stream.
@@ -836,12 +836,12 @@ MHD_websocket_stream_is_valid (struct
MHD_WebSocketStream*ws);
* @ingroup websocket
*/
_MHD_EXTERN enum MHD_WEBSOCKET_STATUS
-MHD_websocket_decode (struct MHD_WebSocketStream* ws,
- const char* streambuf,
+MHD_websocket_decode (struct MHD_WebSocketStream *ws,
+ const char *streambuf,
size_t streambuf_len,
- size_t* streambuf_read_len,
- char** payload,
- size_t* payload_len);
+ size_t *streambuf_read_len,
+ char **payload,
+ size_t *payload_len);
/**
* Splits the payload of a decoded close frame.
@@ -871,11 +871,11 @@ MHD_websocket_decode (struct MHD_WebSocketStream* ws,
* @ingroup websocket
*/
_MHD_EXTERN enum MHD_WEBSOCKET_STATUS
-MHD_websocket_split_close_reason (const char* payload,
+MHD_websocket_split_close_reason (const char *payload,
size_t payload_len,
- unsigned short* reason_code,
- const char** reason_utf8,
- size_t* reason_utf8_len);
+ unsigned short *reason_code,
+ const char **reason_utf8,
+ size_t *reason_utf8_len);
/**
* Encodes an UTF-8 encoded text into websocket text frame.
@@ -913,13 +913,13 @@ MHD_websocket_split_close_reason (const char* payload,
* @ingroup websocket
*/
_MHD_EXTERN enum MHD_WEBSOCKET_STATUS
-MHD_websocket_encode_text (struct MHD_WebSocketStream* ws,
- const char* payload_utf8,
+MHD_websocket_encode_text (struct MHD_WebSocketStream *ws,
+ const char *payload_utf8,
size_t payload_utf8_len,
int fragmentation,
- char** frame,
- size_t* frame_len,
- int* utf8_step);
+ char **frame,
+ size_t *frame_len,
+ int *utf8_step);
/**
* Encodes binary data into websocket binary frame.
@@ -948,12 +948,12 @@ MHD_websocket_encode_text (struct MHD_WebSocketStream* ws,
* @ingroup websocket
*/
_MHD_EXTERN enum MHD_WEBSOCKET_STATUS
-MHD_websocket_encode_binary (struct MHD_WebSocketStream* ws,
- const char* payload,
+MHD_websocket_encode_binary (struct MHD_WebSocketStream *ws,
+ const char *payload,
size_t payload_len,
int fragmentation,
- char** frame,
- size_t* frame_len);
+ char **frame,
+ size_t *frame_len);
/**
* Encodes a websocket ping frame
@@ -977,11 +977,11 @@ MHD_websocket_encode_binary (struct MHD_WebSocketStream*
ws,
* @ingroup websocket
*/
_MHD_EXTERN enum MHD_WEBSOCKET_STATUS
-MHD_websocket_encode_ping (struct MHD_WebSocketStream* ws,
- const char* payload,
+MHD_websocket_encode_ping (struct MHD_WebSocketStream *ws,
+ const char *payload,
size_t payload_len,
- char** frame,
- size_t* frame_len);
+ char **frame,
+ size_t *frame_len);
/**
* Encodes a websocket pong frame
@@ -1010,11 +1010,11 @@ MHD_websocket_encode_ping (struct MHD_WebSocketStream*
ws,
* @ingroup websocket
*/
_MHD_EXTERN enum MHD_WEBSOCKET_STATUS
-MHD_websocket_encode_pong (struct MHD_WebSocketStream* ws,
- const char* payload,
- size_t payload_len,
- char** frame,
- size_t* frame_len);
+MHD_websocket_encode_pong (struct MHD_WebSocketStream *ws,
+ const char *payload,
+ size_t payload_len,
+ char **frame,
+ size_t *frame_len);
/**
* Encodes a websocket close frame
@@ -1052,12 +1052,12 @@ MHD_websocket_encode_pong (struct MHD_WebSocketStream*
ws,
* @ingroup websocket
*/
_MHD_EXTERN enum MHD_WEBSOCKET_STATUS
-MHD_websocket_encode_close (struct MHD_WebSocketStream* ws,
+MHD_websocket_encode_close (struct MHD_WebSocketStream *ws,
unsigned short reason_code,
- const char* reason_utf8,
+ const char *reason_utf8,
size_t reason_utf8_len,
- char** frame,
- size_t* frame_len);
+ char **frame,
+ size_t *frame_len);
/**
* Allocates memory with the associated 'malloc' function
@@ -1069,8 +1069,8 @@ MHD_websocket_encode_close (struct MHD_WebSocketStream*
ws,
* @return The allocated memory on success or NULL on failure.
* @ingroup websocket
*/
-_MHD_EXTERN void*
-MHD_websocket_malloc (struct MHD_WebSocketStream* ws,
+_MHD_EXTERN void *
+MHD_websocket_malloc (struct MHD_WebSocketStream *ws,
size_t buf_len);
/**
@@ -1086,9 +1086,9 @@ MHD_websocket_malloc (struct MHD_WebSocketStream* ws,
* remains valid.
* @ingroup websocket
*/
-_MHD_EXTERN void*
-MHD_websocket_realloc (struct MHD_WebSocketStream* ws,
- void* buf,
+_MHD_EXTERN void *
+MHD_websocket_realloc (struct MHD_WebSocketStream *ws,
+ void *buf,
size_t new_buf_len);
/**
@@ -1104,8 +1104,8 @@ MHD_websocket_realloc (struct MHD_WebSocketStream* ws,
* @ingroup websocket
*/
_MHD_EXTERN int
-MHD_websocket_free (struct MHD_WebSocketStream* ws,
- void* buf);
+MHD_websocket_free (struct MHD_WebSocketStream *ws,
+ void *buf);
#if 0 /* keep Emacsens' auto-indent happy */
{
diff --git a/src/microhttpd_ws/mhd_websocket.c
b/src/microhttpd_ws/mhd_websocket.c
index da787f7d..935deee6 100644
--- a/src/microhttpd_ws/mhd_websocket.c
+++ b/src/microhttpd_ws/mhd_websocket.c
@@ -37,7 +37,7 @@ struct MHD_WebSocketStream
/* The function pointer to free for payload (can be used to use different
memory management) */
MHD_WebSocketFreeCallback free;
/* A closure for the random number generator (only used for client mode;
usually not required) */
- void* cls_rng;
+ void *cls_rng;
/* The random number generator (only used for client mode; usually not
required) */
MHD_WebSocketRandomNumberGenerator rng;
/* The flags specified upon initialization. It may alter the behavior of
decoding/encoding */
@@ -54,11 +54,11 @@ struct MHD_WebSocketStream
/* if != 0 means that we expect a CONTINUATION frame */
char data_type;
/* The start of the current frame (may differ from data_payload for
CONTINUATION frames) */
- char*data_payload_start;
+ char *data_payload_start;
/* The buffer for the data frame */
- char*data_payload;
+ char *data_payload;
/* The buffer for the control frame */
- char*control_payload;
+ char *control_payload;
/* Configuration for the maximum allowed buffer size for payload data */
size_t max_payload_size;
/* The current frame header size */
@@ -127,27 +127,27 @@ enum MHD_WebSocket_UTF8Result
};
static void
-MHD_websocket_copy_payload (char*dst,
- const char*src,
+MHD_websocket_copy_payload (char *dst,
+ const char *src,
size_t len,
uint32_t mask,
unsigned long mask_offset);
static int
-MHD_websocket_check_utf8 (const char*buf,
+MHD_websocket_check_utf8 (const char *buf,
size_t buf_len,
- int*utf8_step,
- size_t*buf_offset);
+ int *utf8_step,
+ size_t *buf_offset);
static enum MHD_WEBSOCKET_STATUS
-MHD_websocket_decode_header_complete (struct MHD_WebSocketStream*ws,
- char**payload,
- size_t*payload_len);
+MHD_websocket_decode_header_complete (struct MHD_WebSocketStream *ws,
+ char **payload,
+ size_t *payload_len);
static enum MHD_WEBSOCKET_STATUS
-MHD_websocket_decode_payload_complete (struct MHD_WebSocketStream*ws,
- char**payload,
- size_t*payload_len);
+MHD_websocket_decode_payload_complete (struct MHD_WebSocketStream *ws,
+ char **payload,
+ size_t *payload_len);
static char
MHD_websocket_encode_is_masked (struct MHD_WebSocketStream *ws);
@@ -156,24 +156,24 @@ MHD_websocket_encode_overhead_size (struct
MHD_WebSocketStream *ws,
size_t payload_len);
static enum MHD_WEBSOCKET_STATUS
-MHD_websocket_encode_data (struct MHD_WebSocketStream*ws,
- const char*payload,
+MHD_websocket_encode_data (struct MHD_WebSocketStream *ws,
+ const char *payload,
size_t payload_len,
int fragmentation,
- char**frame,
- size_t*frame_len,
+ char **frame,
+ size_t *frame_len,
char opcode);
static enum MHD_WEBSOCKET_STATUS
-MHD_websocket_encode_ping_pong (struct MHD_WebSocketStream*ws,
- const char*payload,
+MHD_websocket_encode_ping_pong (struct MHD_WebSocketStream *ws,
+ const char *payload,
size_t payload_len,
- char**frame,
- size_t*frame_len,
+ char **frame,
+ size_t *frame_len,
char opcode);
static uint32_t
-MHD_websocket_generate_mask (struct MHD_WebSocketStream*ws);
+MHD_websocket_generate_mask (struct MHD_WebSocketStream *ws);
static uint16_t
MHD_htons (uint16_t value);
@@ -186,7 +186,7 @@ MHD_htonll (uint64_t value);
* Checks whether the HTTP version is 1.1 or above.
*/
_MHD_EXTERN enum MHD_WEBSOCKET_STATUS
-MHD_websocket_check_http_version (const char* http_version)
+MHD_websocket_check_http_version (const char *http_version)
{
/* validate parameters */
if (NULL == http_version)
@@ -199,11 +199,11 @@ MHD_websocket_check_http_version (const char*
http_version)
/* Check whether the version has a valid format */
/* RFC 1945 3.1: The format must be "HTTP/x.x" where x is */
/* any digit and must appear at least once */
- if ('H' != http_version[0] ||
- 'T' != http_version[1] ||
- 'T' != http_version[2] ||
- 'P' != http_version[3] ||
- '/' != http_version[4])
+ if (('H' != http_version[0]) ||
+ ('T' != http_version[1]) ||
+ ('T' != http_version[2]) ||
+ ('P' != http_version[3]) ||
+ ('/' != http_version[4]))
{
return MHD_WEBSOCKET_STATUS_NO_WEBSOCKET_HANDSHAKE_HEADER;
}
@@ -211,16 +211,16 @@ MHD_websocket_check_http_version (const char*
http_version)
/* Find the major and minor part of the version */
/* RFC 1945 3.1: Both numbers must be threated as separate integers. */
/* Leading zeros must be ignored and both integers may have multiple digits
*/
- const char* major = NULL;
- const char* dot = NULL;
+ const char *major = NULL;
+ const char *dot = NULL;
size_t i = 5;
for (;;)
{
char c = http_version[i];
- if ('0' <= c && '9' >= c)
+ if (('0' <= c) && ('9' >= c))
{
- if (NULL == major ||
- (http_version + i == major + 1 && '0' == *major) )
+ if ((NULL == major) ||
+ ((http_version + i == major + 1) && ('0' == *major)) )
{
major = http_version + i;
}
@@ -237,15 +237,15 @@ MHD_websocket_check_http_version (const char*
http_version)
return MHD_WEBSOCKET_STATUS_NO_WEBSOCKET_HANDSHAKE_HEADER;
}
}
- const char* minor = NULL;
- const char* end = NULL;
+ const char *minor = NULL;
+ const char *end = NULL;
for (;;)
{
char c = http_version[i];
- if ('0' <= c && '9' >= c)
+ if (('0' <= c) && ('9' >= c))
{
- if (NULL == minor ||
- (http_version + i == minor + 1 && '0' == *minor) )
+ if ((NULL == minor) ||
+ ((http_version + i == minor + 1) && ('0' == *minor)) )
{
minor = http_version + i;
}
@@ -261,12 +261,12 @@ MHD_websocket_check_http_version (const char*
http_version)
return MHD_WEBSOCKET_STATUS_NO_WEBSOCKET_HANDSHAKE_HEADER;
}
}
- if (NULL == major || NULL == dot || NULL == minor || NULL == end)
+ if ((NULL == major) || (NULL == dot) || (NULL == minor) || (NULL == end))
{
return MHD_WEBSOCKET_STATUS_NO_WEBSOCKET_HANDSHAKE_HEADER;
}
- if (2 <= dot - major || '2' <= *major ||
- ('1' == *major && (2 <= end - minor || '1' <= *minor)) )
+ if ((2 <= dot - major) || ('2' <= *major) ||
+ (('1' == *major) && ((2 <= end - minor) || ('1' <= *minor))) )
{
return MHD_WEBSOCKET_STATUS_OK;
}
@@ -279,7 +279,7 @@ MHD_websocket_check_http_version (const char* http_version)
* Checks whether the "Connection" request header has the 'Upgrade' token.
*/
_MHD_EXTERN enum MHD_WEBSOCKET_STATUS
-MHD_websocket_check_connection_header (const char* connection_header)
+MHD_websocket_check_connection_header (const char *connection_header)
{
/* validate parameters */
if (NULL == connection_header)
@@ -293,9 +293,9 @@ MHD_websocket_check_connection_header (const char*
connection_header)
/* Check whether the Connection includes an Upgrade token */
/* RFC 7230 6.1: Multiple tokens may appear. */
/* RFC 7230 3.2.6: Tokens are comma separated */
- const char* token_start = NULL;
- const char* token_end = NULL;
- for(size_t i = 0; ; ++i)
+ const char *token_start = NULL;
+ const char *token_end = NULL;
+ for (size_t i = 0; ; ++i)
{
char c = connection_header[i];
@@ -303,12 +303,12 @@ MHD_websocket_check_connection_header (const char*
connection_header)
/* "!" / "#" / "$" / "%" / "&" / "'" / "*" / */
/* "+" / "-" / "." / "^" / "_" / "`" / "|" / "~" */
/* DIGIT / ALPHA */
- if ('!' == c || '#' == c || '$' == c || '%' == c ||
- '&' == c || '\'' == c || '*' == c ||
- '+' == c || '-' == c || '.' == c || '^' == c ||
- '_' == c || '`' == c || '|' == c || '~' == c ||
- ('0' <= c && '9' >= c) ||
- ('A' <= c && 'Z' >= c) || ('a' <= c && 'z' >= c) )
+ if (('!' == c) || ('#' == c) || ('$' == c) || ('%' == c) ||
+ ('&' == c) || ('\'' == c) || ('*' == c) ||
+ ('+' == c) || ('-' == c) || ('.' == c) || ('^' == c) ||
+ ('_' == c) || ('`' == c) || ('|' == c) || ('~' == c) ||
+ (('0' <= c) && ('9' >= c)) ||
+ (('A' <= c) && ('Z' >= c)) || (('a' <= c) && ('z' >= c)) )
{
/* This is a valid token character */
if (NULL == token_start)
@@ -317,24 +317,24 @@ MHD_websocket_check_connection_header (const char*
connection_header)
}
token_end = connection_header + i + 1;
}
- else if (' ' == c || '\t' == c)
+ else if ((' ' == c) || ('\t' == c))
{
/* White-spaces around tokens will be ignored */
}
- else if (',' == c || 0 == c)
+ else if ((',' == c) || (0 == c))
{
/* Check the token (case-insensitive) */
if (NULL != token_start)
{
- if ( 7 == (token_end - token_start) )
+ if (7 == (token_end - token_start) )
{
- if ( ('U' == token_start[0] || 'u' == token_start[0]) &&
- ('P' == token_start[1] || 'p' == token_start[1]) &&
- ('G' == token_start[2] || 'g' == token_start[2]) &&
- ('R' == token_start[3] || 'r' == token_start[3]) &&
- ('A' == token_start[4] || 'a' == token_start[4]) &&
- ('D' == token_start[5] || 'd' == token_start[5]) &&
- ('E' == token_start[6] || 'e' == token_start[6]) )
+ if ( (('U' == token_start[0]) || ('u' == token_start[0])) &&
+ (('P' == token_start[1]) || ('p' == token_start[1])) &&
+ (('G' == token_start[2]) || ('g' == token_start[2])) &&
+ (('R' == token_start[3]) || ('r' == token_start[3])) &&
+ (('A' == token_start[4]) || ('a' == token_start[4])) &&
+ (('D' == token_start[5]) || ('d' == token_start[5])) &&
+ (('E' == token_start[6]) || ('e' == token_start[6])) )
{
/* The token equals to "Upgrade" */
return MHD_WEBSOCKET_STATUS_OK;
@@ -362,7 +362,7 @@ MHD_websocket_check_connection_header (const char*
connection_header)
* Checks whether the "Upgrade" request header has the "websocket" keyword.
*/
_MHD_EXTERN enum MHD_WEBSOCKET_STATUS
-MHD_websocket_check_upgrade_header (const char* upgrade_header)
+MHD_websocket_check_upgrade_header (const char *upgrade_header)
{
/* validate parameters */
if (NULL == upgrade_header)
@@ -376,9 +376,9 @@ MHD_websocket_check_upgrade_header (const char*
upgrade_header)
/* Check whether the Connection includes an Upgrade token */
/* RFC 7230 6.1: Multiple tokens may appear. */
/* RFC 7230 3.2.6: Tokens are comma separated */
- const char* keyword_start = NULL;
- const char* keyword_end = NULL;
- for(size_t i = 0; ; ++i)
+ const char *keyword_start = NULL;
+ const char *keyword_end = NULL;
+ for (size_t i = 0; ; ++i)
{
char c = upgrade_header[i];
@@ -387,13 +387,13 @@ MHD_websocket_check_upgrade_header (const char*
upgrade_header)
/* "+" / "-" / "." / "^" / "_" / "`" / "|" / "~" */
/* DIGIT / ALPHA */
/* We also allow "/" here as the sub-delimiter for the protocol version */
- if ('!' == c || '#' == c || '$' == c || '%' == c ||
- '&' == c || '\'' == c || '*' == c ||
- '+' == c || '-' == c || '.' == c || '^' == c ||
- '_' == c || '`' == c || '|' == c || '~' == c ||
- '/' == c ||
- ('0' <= c && '9' >= c) ||
- ('A' <= c && 'Z' >= c) || ('a' <= c && 'z' >= c) )
+ if (('!' == c) || ('#' == c) || ('$' == c) || ('%' == c) ||
+ ('&' == c) || ('\'' == c) || ('*' == c) ||
+ ('+' == c) || ('-' == c) || ('.' == c) || ('^' == c) ||
+ ('_' == c) || ('`' == c) || ('|' == c) || ('~' == c) ||
+ ('/' == c) ||
+ (('0' <= c) && ('9' >= c)) ||
+ (('A' <= c) && ('Z' >= c)) || (('a' <= c) && ('z' >= c)) )
{
/* This is a valid token character */
if (NULL == keyword_start)
@@ -402,26 +402,26 @@ MHD_websocket_check_upgrade_header (const char*
upgrade_header)
}
keyword_end = upgrade_header + i + 1;
}
- else if (' ' == c || '\t' == c)
+ else if ((' ' == c) || ('\t' == c))
{
/* White-spaces around tokens will be ignored */
}
- else if (',' == c || 0 == c)
+ else if ((',' == c) || (0 == c))
{
/* Check the token (case-insensitive) */
if (NULL != keyword_start)
{
- if ( 9 == (keyword_end - keyword_start) )
+ if (9 == (keyword_end - keyword_start) )
{
- if ( ('W' == keyword_start[0] || 'w' == keyword_start[0]) &&
- ('E' == keyword_start[1] || 'e' == keyword_start[1]) &&
- ('B' == keyword_start[2] || 'b' == keyword_start[2]) &&
- ('S' == keyword_start[3] || 's' == keyword_start[3]) &&
- ('O' == keyword_start[4] || 'o' == keyword_start[4]) &&
- ('C' == keyword_start[5] || 'c' == keyword_start[5]) &&
- ('K' == keyword_start[6] || 'k' == keyword_start[6]) &&
- ('E' == keyword_start[7] || 'e' == keyword_start[7]) &&
- ('T' == keyword_start[8] || 't' == keyword_start[8]) )
+ if ( (('W' == keyword_start[0]) || ('w' == keyword_start[0])) &&
+ (('E' == keyword_start[1]) || ('e' == keyword_start[1])) &&
+ (('B' == keyword_start[2]) || ('b' == keyword_start[2])) &&
+ (('S' == keyword_start[3]) || ('s' == keyword_start[3])) &&
+ (('O' == keyword_start[4]) || ('o' == keyword_start[4])) &&
+ (('C' == keyword_start[5]) || ('c' == keyword_start[5])) &&
+ (('K' == keyword_start[6]) || ('k' == keyword_start[6])) &&
+ (('E' == keyword_start[7]) || ('e' == keyword_start[7])) &&
+ (('T' == keyword_start[8]) || ('t' == keyword_start[8])) )
{
/* The keyword equals to "websocket" */
return MHD_WEBSOCKET_STATUS_OK;
@@ -450,7 +450,7 @@ MHD_websocket_check_upgrade_header (const char*
upgrade_header)
* equals to "13"
*/
_MHD_EXTERN enum MHD_WEBSOCKET_STATUS
-MHD_websocket_check_version_header (const char* version_header)
+MHD_websocket_check_version_header (const char *version_header)
{
/* validate parameters */
if (NULL == version_header)
@@ -461,9 +461,9 @@ MHD_websocket_check_version_header (const char*
version_header)
return MHD_WEBSOCKET_STATUS_NO_WEBSOCKET_HANDSHAKE_HEADER;
}
- if ('1' == version_header[0] &&
- '3' == version_header[1] &&
- 0 == version_header[2])
+ if (('1' == version_header[0]) &&
+ ('3' == version_header[1]) &&
+ (0 == version_header[2]))
{
/* The version equals to "13" */
return MHD_WEBSOCKET_STATUS_OK;
@@ -476,8 +476,8 @@ MHD_websocket_check_version_header (const char*
version_header)
* Creates the response for the Sec-WebSocket-Accept header
*/
_MHD_EXTERN enum MHD_WEBSOCKET_STATUS
-MHD_websocket_create_accept_header (const char*sec_websocket_key,
- char*sec_websocket_accept)
+MHD_websocket_create_accept_header (const char *sec_websocket_key,
+ char *sec_websocket_accept)
{
/* initialize output variables for errors cases */
if (NULL != sec_websocket_accept)
@@ -498,18 +498,18 @@ MHD_websocket_create_accept_header (const
char*sec_websocket_key,
/* build SHA1 hash of the given key and the UUID appended */
char sha1[20];
- const char*suffix = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11";
+ const char *suffix = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11";
int length = (int) strlen (sec_websocket_key);
struct sha1_ctx ctx;
MHD_SHA1_init (&ctx);
- MHD_SHA1_update (&ctx, (const uint8_t*) sec_websocket_key, length);
- MHD_SHA1_update (&ctx, (const uint8_t*) suffix, 36);
- MHD_SHA1_finish (&ctx, (uint8_t*) sha1);
+ MHD_SHA1_update (&ctx, (const uint8_t *) sec_websocket_key, length);
+ MHD_SHA1_update (&ctx, (const uint8_t *) suffix, 36);
+ MHD_SHA1_finish (&ctx, (uint8_t *) sha1);
/* base64 encode that SHA1 hash */
/* (simple algorithm here; SHA1 has always 20 bytes, */
/* which will always result in a 28 bytes base64 hash) */
- const char*base64_encoding_table =
+ const char *base64_encoding_table =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
for (int i = 0, j = 0; i < 20;)
{
@@ -535,7 +535,7 @@ MHD_websocket_create_accept_header (const
char*sec_websocket_key,
* Initializes a new websocket stream
*/
_MHD_EXTERN enum MHD_WEBSOCKET_STATUS
-MHD_websocket_stream_init (struct MHD_WebSocketStream**ws,
+MHD_websocket_stream_init (struct MHD_WebSocketStream **ws,
int flags,
size_t max_payload_size)
{
@@ -555,13 +555,13 @@ MHD_websocket_stream_init (struct MHD_WebSocketStream**ws,
* additional parameters for allocation functions
*/
_MHD_EXTERN enum MHD_WEBSOCKET_STATUS
-MHD_websocket_stream_init2 (struct MHD_WebSocketStream**ws,
+MHD_websocket_stream_init2 (struct MHD_WebSocketStream **ws,
int flags,
size_t max_payload_size,
MHD_WebSocketMallocCallback callback_malloc,
MHD_WebSocketReallocCallback callback_realloc,
MHD_WebSocketFreeCallback callback_free,
- void* cls_rng,
+ void *cls_rng,
MHD_WebSocketRandomNumberGenerator callback_rng)
{
/* initialize output variables for errors cases */
@@ -576,13 +576,13 @@ MHD_websocket_stream_init2 (struct
MHD_WebSocketStream**ws,
(NULL == callback_realloc) ||
(NULL == callback_free) ||
((0 != (flags & MHD_WEBSOCKET_FLAG_CLIENT)) &&
- (NULL == callback_rng)))
+ (NULL == callback_rng)))
{
return MHD_WEBSOCKET_STATUS_PARAMETER_ERROR;
}
/* allocate stream */
- struct MHD_WebSocketStream*ws_ = (struct MHD_WebSocketStream*) malloc (
+ struct MHD_WebSocketStream *ws_ = (struct MHD_WebSocketStream *) malloc (
sizeof (struct MHD_WebSocketStream));
if (NULL == ws_)
return MHD_WEBSOCKET_STATUS_MEMORY_ERROR;
@@ -609,7 +609,7 @@ MHD_websocket_stream_init2 (struct MHD_WebSocketStream**ws,
* Frees a previously allocated websocket stream
*/
_MHD_EXTERN enum MHD_WEBSOCKET_STATUS
-MHD_websocket_stream_free (struct MHD_WebSocketStream*ws)
+MHD_websocket_stream_free (struct MHD_WebSocketStream *ws)
{
/* validate parameters */
if (NULL == ws)
@@ -632,7 +632,7 @@ MHD_websocket_stream_free (struct MHD_WebSocketStream*ws)
* Invalidates a websocket stream (no more decoding possible)
*/
_MHD_EXTERN enum MHD_WEBSOCKET_STATUS
-MHD_websocket_stream_invalidate (struct MHD_WebSocketStream*ws)
+MHD_websocket_stream_invalidate (struct MHD_WebSocketStream *ws)
{
/* validate parameters */
if (NULL == ws)
@@ -649,7 +649,7 @@ MHD_websocket_stream_invalidate (struct
MHD_WebSocketStream*ws)
* Returns whether a websocket stream is valid
*/
_MHD_EXTERN enum MHD_WEBSOCKET_VALIDITY
-MHD_websocket_stream_is_valid (struct MHD_WebSocketStream*ws)
+MHD_websocket_stream_is_valid (struct MHD_WebSocketStream *ws)
{
/* validate parameters */
if (NULL == ws)
@@ -663,12 +663,12 @@ MHD_websocket_stream_is_valid (struct
MHD_WebSocketStream*ws)
* Decodes incoming data to a websocket frame
*/
_MHD_EXTERN enum MHD_WEBSOCKET_STATUS
-MHD_websocket_decode (struct MHD_WebSocketStream*ws,
- const char*streambuf,
+MHD_websocket_decode (struct MHD_WebSocketStream *ws,
+ const char *streambuf,
size_t streambuf_len,
- size_t*streambuf_read_len,
- char**payload,
- size_t*payload_len)
+ size_t *streambuf_read_len,
+ char **payload,
+ size_t *payload_len)
{
/* initialize output variables for errors cases */
if (NULL != streambuf_read_len)
@@ -1021,7 +1021,8 @@ MHD_websocket_decode (struct MHD_WebSocketStream*ws,
case MHD_WebSocket_DecodeStep_Length2of2:
{
ws->frame_header [ws->frame_header_size++] = streambuf [current++];
- size_t size = (size_t) MHD_htons (*((uint16_t*) &ws->frame_header
[2]));
+ size_t size = (size_t) MHD_htons (
+ *((uint16_t *) &ws->frame_header [2]));
if (125 >= size)
{
/* RFC 6455 5.2 Payload length: The minimal number of bytes */
@@ -1078,7 +1079,7 @@ MHD_websocket_decode (struct MHD_WebSocketStream*ws,
case MHD_WebSocket_DecodeStep_Length8of8:
{
ws->frame_header [ws->frame_header_size++] = streambuf [current++];
- uint64_t size = MHD_htonll (*((uint64_t*) &ws->frame_header [2]));
+ uint64_t size = MHD_htonll (*((uint64_t *) &ws->frame_header [2]));
if (0x7fffffffffffffff < size)
{
/* RFC 6455 5.2 frame-payload-length-63: The length may */
@@ -1201,16 +1202,16 @@ MHD_websocket_decode (struct MHD_WebSocketStream*ws,
current += bytes_to_take;
ws->payload_index += bytes_to_take;
if (((MHD_WebSocket_DecodeStep_PayloadOfDataFrame ==
- ws->decode_step) &&
- (MHD_WebSocket_Opcode_Text == ws->data_type)) ||
+ ws->decode_step) &&
+ (MHD_WebSocket_Opcode_Text == ws->data_type)) ||
((MHD_WebSocket_DecodeStep_PayloadOfControlFrame ==
- ws->decode_step) &&
- (MHD_WebSocket_Opcode_Close == (ws->frame_header [0] & 0x0f)) &&
- (2 < ws->payload_index)) )
+ ws->decode_step) &&
+ (MHD_WebSocket_Opcode_Close == (ws->frame_header [0] & 0x0f)) &&
+ (2 < ws->payload_index)) )
{
/* RFC 6455 8.1: We need to check the UTF-8 validity */
int utf8_step;
- char*decode_payload_utf8;
+ char *decode_payload_utf8;
size_t bytes_to_check;
size_t utf8_error_offset = 0;
if (MHD_WebSocket_DecodeStep_PayloadOfDataFrame == ws->decode_step)
@@ -1324,9 +1325,9 @@ MHD_websocket_decode (struct MHD_WebSocketStream*ws,
static enum MHD_WEBSOCKET_STATUS
-MHD_websocket_decode_header_complete (struct MHD_WebSocketStream*ws,
- char**payload,
- size_t*payload_len)
+MHD_websocket_decode_header_complete (struct MHD_WebSocketStream *ws,
+ char **payload,
+ size_t *payload_len)
{
/* assign either to data or control */
char opcode = ws->frame_header [0] & 0x0f;
@@ -1356,7 +1357,7 @@ MHD_websocket_decode_header_complete (struct
MHD_WebSocketStream*ws,
return MHD_WEBSOCKET_STATUS_MAXIMUM_SIZE_EXCEEDED;
}
/* allocate buffer for continued data frame */
- char*new_buf = NULL;
+ char *new_buf = NULL;
if (0 != new_size_total)
{
new_buf = ws->realloc (ws->data_payload, new_size_total + 1);
@@ -1382,7 +1383,7 @@ MHD_websocket_decode_header_complete (struct
MHD_WebSocketStream*ws,
/* allocate buffer for data frame */
{
size_t new_size_total = ws->payload_size;
- char*new_buf = NULL;
+ char *new_buf = NULL;
if (0 != new_size_total)
{
new_buf = ws->malloc (new_size_total + 1);
@@ -1406,7 +1407,7 @@ MHD_websocket_decode_header_complete (struct
MHD_WebSocketStream*ws,
/* allocate buffer for control frame */
{
size_t new_size_total = ws->payload_size;
- char*new_buf = NULL;
+ char *new_buf = NULL;
if (0 != new_size_total)
{
new_buf = ws->malloc (new_size_total + 1);
@@ -1427,13 +1428,13 @@ MHD_websocket_decode_header_complete (struct
MHD_WebSocketStream*ws,
static enum MHD_WEBSOCKET_STATUS
-MHD_websocket_decode_payload_complete (struct MHD_WebSocketStream*ws,
- char**payload,
- size_t*payload_len)
+MHD_websocket_decode_payload_complete (struct MHD_WebSocketStream *ws,
+ char **payload,
+ size_t *payload_len)
{
/* all payload data of the current frame has been received */
char is_continue = MHD_WebSocket_Opcode_Continuation ==
- (ws->frame_header [0] & 0x0F);
+ (ws->frame_header [0] & 0x0F);
char is_fin = ws->frame_header [0] & 0x80;
if (0 != is_fin)
{
@@ -1567,11 +1568,11 @@ MHD_websocket_decode_payload_complete (struct
MHD_WebSocketStream*ws,
* Splits the received close reason
*/
_MHD_EXTERN enum MHD_WEBSOCKET_STATUS
-MHD_websocket_split_close_reason (const char*payload,
+MHD_websocket_split_close_reason (const char *payload,
size_t payload_len,
- unsigned short*reason_code,
- const char**reason_utf8,
- size_t*reason_utf8_len)
+ unsigned short *reason_code,
+ const char **reason_utf8,
+ size_t *reason_utf8_len)
{
/* initialize output variables for errors cases */
if (NULL != reason_code)
@@ -1598,7 +1599,7 @@ MHD_websocket_split_close_reason (const char*payload,
else
{
if (NULL != reason_code)
- *reason_code = MHD_htons (*((uint16_t*) payload));
+ *reason_code = MHD_htons (*((uint16_t *) payload));
}
/* decode reason text */
@@ -1625,13 +1626,13 @@ MHD_websocket_split_close_reason (const char*payload,
* Encodes a text into a websocket text frame
*/
_MHD_EXTERN enum MHD_WEBSOCKET_STATUS
-MHD_websocket_encode_text (struct MHD_WebSocketStream*ws,
- const char*payload_utf8,
+MHD_websocket_encode_text (struct MHD_WebSocketStream *ws,
+ const char *payload_utf8,
size_t payload_utf8_len,
int fragmentation,
- char**frame,
- size_t*frame_len,
- int*utf8_step)
+ char **frame,
+ size_t *frame_len,
+ int *utf8_step)
{
/* initialize output variables for errors cases */
if (NULL != frame)
@@ -1654,7 +1655,7 @@ MHD_websocket_encode_text (struct MHD_WebSocketStream*ws,
(MHD_WEBSOCKET_FRAGMENTATION_NONE > fragmentation) ||
(MHD_WEBSOCKET_FRAGMENTATION_LAST < fragmentation) ||
((MHD_WEBSOCKET_FRAGMENTATION_NONE != fragmentation) &&
- (NULL == utf8_step)) )
+ (NULL == utf8_step)) )
{
return MHD_WEBSOCKET_STATUS_PARAMETER_ERROR;
}
@@ -1672,7 +1673,7 @@ MHD_websocket_encode_text (struct MHD_WebSocketStream*ws,
NULL);
if ((MHD_WebSocket_UTF8Result_Invalid == utf8_result) ||
((MHD_WebSocket_UTF8Result_Incomplete == utf8_result) &&
- (MHD_WEBSOCKET_FRAGMENTATION_NONE == fragmentation)) )
+ (MHD_WEBSOCKET_FRAGMENTATION_NONE == fragmentation)) )
{
return MHD_WEBSOCKET_STATUS_UTF8_ENCODING_ERROR;
}
@@ -1692,12 +1693,12 @@ MHD_websocket_encode_text (struct
MHD_WebSocketStream*ws,
* Encodes binary data into a websocket binary frame
*/
_MHD_EXTERN enum MHD_WEBSOCKET_STATUS
-MHD_websocket_encode_binary (struct MHD_WebSocketStream*ws,
- const char*payload,
+MHD_websocket_encode_binary (struct MHD_WebSocketStream *ws,
+ const char *payload,
size_t payload_len,
int fragmentation,
- char**frame,
- size_t*frame_len)
+ char **frame,
+ size_t *frame_len)
{
/* initialize output variables for errors cases */
if (NULL != frame)
@@ -1736,12 +1737,12 @@ MHD_websocket_encode_binary (struct
MHD_WebSocketStream*ws,
* Internal function for encoding text/binary data into a websocket frame
*/
static enum MHD_WEBSOCKET_STATUS
-MHD_websocket_encode_data (struct MHD_WebSocketStream*ws,
- const char*payload,
+MHD_websocket_encode_data (struct MHD_WebSocketStream *ws,
+ const char *payload,
size_t payload_len,
int fragmentation,
- char**frame,
- size_t*frame_len,
+ char **frame,
+ size_t *frame_len,
char opcode)
{
/* calculate length and masking */
@@ -1751,7 +1752,7 @@ MHD_websocket_encode_data (struct MHD_WebSocketStream*ws,
uint32_t mask = 0 != is_masked ? MHD_websocket_generate_mask (ws) : 0;
/* allocate memory */
- char*result = ws->malloc (total_len + 1);
+ char *result = ws->malloc (total_len + 1);
if (NULL == result)
return MHD_WEBSOCKET_STATUS_MEMORY_ERROR;
result [total_len] = 0;
@@ -1821,11 +1822,11 @@ MHD_websocket_encode_data (struct
MHD_WebSocketStream*ws,
* Encodes a websocket ping frame
*/
_MHD_EXTERN enum MHD_WEBSOCKET_STATUS
-MHD_websocket_encode_ping (struct MHD_WebSocketStream*ws,
- const char*payload,
+MHD_websocket_encode_ping (struct MHD_WebSocketStream *ws,
+ const char *payload,
size_t payload_len,
- char**frame,
- size_t*frame_len)
+ char **frame,
+ size_t *frame_len)
{
/* encode the ping frame */
return MHD_websocket_encode_ping_pong (ws,
@@ -1841,11 +1842,11 @@ MHD_websocket_encode_ping (struct
MHD_WebSocketStream*ws,
* Encodes a websocket pong frame
*/
_MHD_EXTERN enum MHD_WEBSOCKET_STATUS
-MHD_websocket_encode_pong (struct MHD_WebSocketStream*ws,
- const char*payload,
+MHD_websocket_encode_pong (struct MHD_WebSocketStream *ws,
+ const char *payload,
size_t payload_len,
- char**frame,
- size_t*frame_len)
+ char **frame,
+ size_t *frame_len)
{
/* encode the pong frame */
return MHD_websocket_encode_ping_pong (ws,
@@ -1861,11 +1862,11 @@ MHD_websocket_encode_pong (struct
MHD_WebSocketStream*ws,
* Internal function for encoding ping/pong frames
*/
static enum MHD_WEBSOCKET_STATUS
-MHD_websocket_encode_ping_pong (struct MHD_WebSocketStream*ws,
- const char*payload,
+MHD_websocket_encode_ping_pong (struct MHD_WebSocketStream *ws,
+ const char *payload,
size_t payload_len,
- char**frame,
- size_t*frame_len,
+ char **frame,
+ size_t *frame_len,
char opcode)
{
/* initialize output variables for errors cases */
@@ -1894,7 +1895,7 @@ MHD_websocket_encode_ping_pong (struct
MHD_WebSocketStream*ws,
uint32_t mask = is_masked != 0 ? MHD_websocket_generate_mask (ws) : 0;
/* allocate memory */
- char*result = ws->malloc (total_len + 1);
+ char *result = ws->malloc (total_len + 1);
if (NULL == result)
return MHD_WEBSOCKET_STATUS_MEMORY_ERROR;
result [total_len] = 0;
@@ -1934,12 +1935,12 @@ MHD_websocket_encode_ping_pong (struct
MHD_WebSocketStream*ws,
* Encodes a websocket close frame
*/
_MHD_EXTERN enum MHD_WEBSOCKET_STATUS
-MHD_websocket_encode_close (struct MHD_WebSocketStream*ws,
+MHD_websocket_encode_close (struct MHD_WebSocketStream *ws,
unsigned short reason_code,
- const char*reason_utf8,
+ const char *reason_utf8,
size_t reason_utf8_len,
- char**frame,
- size_t*frame_len)
+ char **frame,
+ size_t *frame_len)
{
/* initialize output variables for errors cases */
if (NULL != frame)
@@ -1953,9 +1954,9 @@ MHD_websocket_encode_close (struct MHD_WebSocketStream*ws,
(NULL == frame) ||
(NULL == frame_len) ||
((MHD_WEBSOCKET_CLOSEREASON_NO_REASON != reason_code) &&
- (1000 > reason_code)) ||
+ (1000 > reason_code)) ||
((0 != reason_utf8_len) &&
- (MHD_WEBSOCKET_CLOSEREASON_NO_REASON == reason_code)) )
+ (MHD_WEBSOCKET_CLOSEREASON_NO_REASON == reason_code)) )
{
return MHD_WEBSOCKET_STATUS_PARAMETER_ERROR;
}
@@ -1986,7 +1987,7 @@ MHD_websocket_encode_close (struct MHD_WebSocketStream*ws,
uint32_t mask = is_masked != 0 ? MHD_websocket_generate_mask (ws) : 0;
/* allocate memory */
- char*result = ws->malloc (total_len + 1);
+ char *result = ws->malloc (total_len + 1);
if (NULL == result)
return MHD_WEBSOCKET_STATUS_MEMORY_ERROR;
result [total_len] = 0;
@@ -2014,7 +2015,7 @@ MHD_websocket_encode_close (struct MHD_WebSocketStream*ws,
/* close reason code */
uint16_t reason_code_nb = MHD_htons (reason_code);
MHD_websocket_copy_payload (result,
- (const char*) &reason_code_nb,
+ (const char *) &reason_code_nb,
2,
mask,
0);
@@ -2039,7 +2040,7 @@ MHD_websocket_encode_close (struct MHD_WebSocketStream*ws,
* Returns the 0x80 prefix for masked data, 0x00 otherwise
*/
static char
-MHD_websocket_encode_is_masked (struct MHD_WebSocketStream*ws)
+MHD_websocket_encode_is_masked (struct MHD_WebSocketStream *ws)
{
return (ws->flags & MHD_WEBSOCKET_FLAG_MASK_SERVERCLIENT) ==
MHD_WEBSOCKET_FLAG_CLIENT ? 0x80 : 0x00;
@@ -2050,7 +2051,7 @@ MHD_websocket_encode_is_masked (struct
MHD_WebSocketStream*ws)
* Calculates the size of the overhead in bytes
*/
static char
-MHD_websocket_encode_overhead_size (struct MHD_WebSocketStream*ws,
+MHD_websocket_encode_overhead_size (struct MHD_WebSocketStream *ws,
size_t payload_len)
{
return 2 + (MHD_websocket_encode_is_masked (ws) != 0 ? 4 : 0) + (125 <
@@ -2065,8 +2066,8 @@ MHD_websocket_encode_overhead_size (struct
MHD_WebSocketStream*ws,
* Copies the payload to the destination (using mask)
*/
static void
-MHD_websocket_copy_payload (char*dst,
- const char*src,
+MHD_websocket_copy_payload (char *dst,
+ const char *src,
size_t len,
uint32_t mask,
unsigned long mask_offset)
@@ -2096,10 +2097,10 @@ MHD_websocket_copy_payload (char*dst,
* Checks a UTF-8 sequence
*/
static int
-MHD_websocket_check_utf8 (const char*buf,
+MHD_websocket_check_utf8 (const char *buf,
size_t buf_len,
- int*utf8_step,
- size_t*buf_offset)
+ int *utf8_step,
+ size_t *buf_offset)
{
int utf8_step_ = (NULL != utf8_step) ? *utf8_step :
MHD_WEBSOCKET_UTF8STEP_NORMAL;
@@ -2310,7 +2311,7 @@ MHD_websocket_check_utf8 (const char*buf,
* a random number generator.
*/
static uint32_t
-MHD_websocket_generate_mask (struct MHD_WebSocketStream*ws)
+MHD_websocket_generate_mask (struct MHD_WebSocketStream *ws)
{
unsigned char mask_[4];
if (NULL != ws->rng)
@@ -2340,8 +2341,8 @@ MHD_websocket_generate_mask (struct
MHD_WebSocketStream*ws)
/**
* Calls the malloc function associated with the websocket steam
*/
-_MHD_EXTERN void*
-MHD_websocket_malloc (struct MHD_WebSocketStream* ws,
+_MHD_EXTERN void *
+MHD_websocket_malloc (struct MHD_WebSocketStream *ws,
size_t buf_len)
{
if (NULL == ws)
@@ -2356,9 +2357,9 @@ MHD_websocket_malloc (struct MHD_WebSocketStream* ws,
/**
* Calls the realloc function associated with the websocket steam
*/
-_MHD_EXTERN void*
-MHD_websocket_realloc (struct MHD_WebSocketStream* ws,
- void* buf,
+_MHD_EXTERN void *
+MHD_websocket_realloc (struct MHD_WebSocketStream *ws,
+ void *buf,
size_t new_buf_len)
{
if (NULL == ws)
@@ -2374,8 +2375,8 @@ MHD_websocket_realloc (struct MHD_WebSocketStream* ws,
* Calls the free function associated with the websocket steam
*/
_MHD_EXTERN int
-MHD_websocket_free (struct MHD_WebSocketStream* ws,
- void* buf)
+MHD_websocket_free (struct MHD_WebSocketStream *ws,
+ void *buf)
{
if (NULL == ws)
{
@@ -2387,6 +2388,7 @@ MHD_websocket_free (struct MHD_WebSocketStream* ws,
return MHD_WEBSOCKET_STATUS_OK;
}
+
/**
* Converts a 16 bit value into network byte order (MSB first)
* in dependence of the host system
@@ -2410,6 +2412,7 @@ MHD_htons (uint16_t value)
}
}
+
/**
* Converts a 64 bit value into network byte order (MSB first)
* in dependence of the host system
diff --git a/src/microhttpd_ws/sha1.c b/src/microhttpd_ws/sha1.c
index 9888cbfe..1e9da5c7 100644
--- a/src/microhttpd_ws/sha1.c
+++ b/src/microhttpd_ws/sha1.c
@@ -116,7 +116,7 @@ sha1_transform (uint32_t H[_SHA1_DIGEST_LENGTH],
/* The W[] buffer itself will be used as the source of the data,
* but data will be reloaded in correct bytes order during
* the next steps */
- data = (uint8_t*) W;
+ data = (uint8_t *) W;
}
#endif /* _MHD_GET_32BIT_BE_UNALIGNED */
diff --git a/src/microhttpd_ws/test_websocket.c
b/src/microhttpd_ws/test_websocket.c
index 29a4661a..00fd8e03 100644
--- a/src/microhttpd_ws/test_websocket.c
+++ b/src/microhttpd_ws/test_websocket.c
@@ -40,12 +40,12 @@ size_t open_allocs = 0;
/**
* Custom `malloc()` function used for memory tests
*/
-static void*
+static void *
test_malloc (size_t buf_len)
{
if (0 != disable_alloc)
return NULL;
- void*result = malloc (buf_len);
+ void *result = malloc (buf_len);
if (NULL != result)
++open_allocs;
return result;
@@ -55,12 +55,12 @@ test_malloc (size_t buf_len)
/**
* Custom `realloc()` function used for memory tests
*/
-static void*
-test_realloc (void*buf, size_t buf_len)
+static void *
+test_realloc (void *buf, size_t buf_len)
{
if (0 != disable_alloc)
return NULL;
- void*result = realloc (buf, buf_len);
+ void *result = realloc (buf, buf_len);
if ((NULL != result) && (NULL == buf))
++open_allocs;
return result;
@@ -71,22 +71,23 @@ test_realloc (void*buf, size_t buf_len)
* Custom `free()` function used for memory tests
*/
static void
-test_free (void*buf)
+test_free (void *buf)
{
if (NULL != buf)
--open_allocs;
free (buf);
}
+
/**
* Custom `rng()` function used for client mode tests
*/
static size_t
-test_rng (void*cls, void*buf, size_t buf_len)
+test_rng (void *cls, void *buf, size_t buf_len)
{
for (size_t i = 0; i < buf_len; ++i)
{
- ((char*) buf) [i] = (char) (rand () % 0xFF);
+ ((char *) buf) [i] = (char) (rand () % 0xFF);
}
return buf_len;
@@ -97,18 +98,18 @@ test_rng (void*cls, void*buf, size_t buf_len)
* Helper function which allocates a big amount of data
*/
static void
-allocate_length_test_data (char**buf1,
- char**buf2,
+allocate_length_test_data (char **buf1,
+ char **buf2,
size_t buf_len,
- const char*buf1_prefix,
+ const char *buf1_prefix,
size_t buf1_prefix_len)
{
if (NULL != *buf1)
free (*buf1);
if (NULL != *buf2)
free (*buf2);
- *buf1 = (char*) malloc (buf_len + buf1_prefix_len);
- *buf2 = (char*) malloc (buf_len);
+ *buf1 = (char *) malloc (buf_len + buf1_prefix_len);
+ *buf2 = (char *) malloc (buf_len);
if ((NULL == buf1) || (NULL == buf2))
return;
memcpy (*buf1,
@@ -136,8 +137,8 @@ static int
test_decode_single (unsigned int test_line,
int flags, size_t max_payload_size, size_t decode_count,
size_t buf_step,
- const char*buf, size_t buf_len,
- const char*expected_payload, size_t expected_payload_len,
+ const char *buf, size_t buf_len,
+ const char *expected_payload, size_t expected_payload_len,
int expected_return, int expected_valid, size_t
expected_streambuf_read_len)
{
@@ -164,7 +165,7 @@ test_decode_single (unsigned int test_line,
/* perform decoding in a loop */
size_t streambuf_read_len = 0;
size_t payload_len = 0;
- char*payload = NULL;
+ char *payload = NULL;
for (size_t i = 0; i < decode_count; ++i)
{
size_t streambuf_read_len_ = 0;
@@ -299,7 +300,7 @@ int
test_inits ()
{
int failed = 0;
- struct MHD_WebSocketStream*ws;
+ struct MHD_WebSocketStream *ws;
int ret;
/*
@@ -315,11 +316,11 @@ test_inits ()
i,
0);
if (((0 == (i & MHD_WEBSOCKET_FLAG_CLIENT)) &&
- ((MHD_WEBSOCKET_STATUS_OK != ret) ||
- (NULL == ws))) ||
+ ((MHD_WEBSOCKET_STATUS_OK != ret) ||
+ (NULL == ws))) ||
((0 != (i & MHD_WEBSOCKET_FLAG_CLIENT)) &&
- ((MHD_WEBSOCKET_STATUS_OK == ret) ||
- (NULL != ws))))
+ ((MHD_WEBSOCKET_STATUS_OK == ret) ||
+ (NULL != ws))))
{
fprintf (stderr,
"Init test failed in line %u for flags %d.\n",
@@ -788,7 +789,7 @@ test_inits ()
test_malloc,
test_realloc,
test_free,
- (void*) 12345,
+ (void *) 12345,
test_rng);
if ((MHD_WEBSOCKET_STATUS_OK != ret) ||
(NULL == ws) )
@@ -3595,7 +3596,7 @@ test_decodes ()
0);
/* Failure test: Call after invalidated stream (but with different buffer) */
{
- struct MHD_WebSocketStream*ws;
+ struct MHD_WebSocketStream *ws;
if (MHD_WEBSOCKET_STATUS_OK == MHD_websocket_stream_init (&ws,
MHD_WEBSOCKET_FLAG_SERVER
|
@@ -3603,7 +3604,7 @@ test_decodes ()
0))
{
size_t streambuf_read_len = 0;
- char*payload = NULL;
+ char *payload = NULL;
size_t payload_len = 0;
int ret = 0;
ret = MHD_websocket_decode (ws,
@@ -4235,7 +4236,7 @@ test_decodes ()
------------------------------------------------------------------------------
*/
{
- struct MHD_WebSocketStream*ws;
+ struct MHD_WebSocketStream *ws;
if (MHD_WEBSOCKET_STATUS_OK == MHD_websocket_stream_init (&ws,
MHD_WEBSOCKET_FLAG_SERVER
|
@@ -4243,7 +4244,7 @@ test_decodes ()
0))
{
size_t streambuf_read_len = 0;
- char*payload = NULL;
+ char *payload = NULL;
size_t payload_len = 0;
int ret = 0;
@@ -4352,7 +4353,7 @@ test_decodes ()
}
}
{
- struct MHD_WebSocketStream*ws;
+ struct MHD_WebSocketStream *ws;
if (MHD_WEBSOCKET_STATUS_OK == MHD_websocket_stream_init (&ws,
MHD_WEBSOCKET_FLAG_SERVER
|
@@ -4360,7 +4361,7 @@ test_decodes ()
0))
{
size_t streambuf_read_len = 0;
- char*payload = NULL;
+ char *payload = NULL;
size_t payload_len = 0;
int ret = 0;
@@ -4480,7 +4481,7 @@ test_decodes ()
------------------------------------------------------------------------------
*/
{
- struct MHD_WebSocketStream*ws;
+ struct MHD_WebSocketStream *ws;
if (MHD_WEBSOCKET_STATUS_OK == MHD_websocket_stream_init (&ws,
MHD_WEBSOCKET_FLAG_SERVER
|
@@ -4488,7 +4489,7 @@ test_decodes ()
0))
{
size_t streambuf_read_len = 0;
- char*payload = NULL;
+ char *payload = NULL;
size_t payload_len = 0;
int ret = 0;
@@ -4699,7 +4700,7 @@ test_decodes ()
------------------------------------------------------------------------------
*/
{
- struct MHD_WebSocketStream*ws;
+ struct MHD_WebSocketStream *ws;
if (MHD_WEBSOCKET_STATUS_OK == MHD_websocket_stream_init2 (&ws,
MHD_WEBSOCKET_FLAG_SERVER
|
@@ -4712,7 +4713,7 @@ test_decodes ()
NULL))
{
size_t streambuf_read_len = 0;
- char*payload = NULL;
+ char *payload = NULL;
size_t payload_len = 0;
int ret = 0;
@@ -4880,9 +4881,9 @@ test_decodes ()
*/
{
disable_alloc = 0;
- struct MHD_WebSocketStream*ws;
+ struct MHD_WebSocketStream *ws;
size_t streambuf_read_len = 0;
- char*payload = NULL;
+ char *payload = NULL;
size_t payload_len = 0;
int ret = 0;
@@ -5203,11 +5204,11 @@ int
test_encodes_text ()
{
int failed = 0;
- struct MHD_WebSocketStream*wss;
- struct MHD_WebSocketStream*wsc;
+ struct MHD_WebSocketStream *wss;
+ struct MHD_WebSocketStream *wsc;
int ret;
char *buf1 = NULL, *buf2 = NULL;
- char*frame = NULL;
+ char *frame = NULL;
size_t frame_len = 0;
int utf8_step = 0;
@@ -6062,7 +6063,7 @@ test_encodes_text ()
------------------------------------------------------------------------------
*/
/* Fail test: `ws` not passed */
- frame = (char*) (uintptr_t) 0xBAADF00D;
+ frame = (char *) (uintptr_t) 0xBAADF00D;
frame_len = 0x87654321;
ret = MHD_websocket_encode_text (NULL,
"abc",
@@ -6080,7 +6081,7 @@ test_encodes_text ()
(unsigned int) __LINE__);
++failed;
}
- if (((char*) (uintptr_t) 0xBAADF00D) == frame)
+ if (((char *) (uintptr_t) 0xBAADF00D) == frame)
{
frame = NULL;
}
@@ -6090,7 +6091,7 @@ test_encodes_text ()
frame = NULL;
}
/* Fail test: `payload_utf8` not passed, but `payload_utf8_len` != 0 */
- frame = (char*) (uintptr_t) 0xBAADF00D;
+ frame = (char *) (uintptr_t) 0xBAADF00D;
frame_len = 0x87654321;
ret = MHD_websocket_encode_text (wss,
NULL,
@@ -6108,7 +6109,7 @@ test_encodes_text ()
(unsigned int) __LINE__);
++failed;
}
- if (((char*) (uintptr_t) 0xBAADF00D) == frame)
+ if (((char *) (uintptr_t) 0xBAADF00D) == frame)
{
frame = NULL;
}
@@ -6118,7 +6119,7 @@ test_encodes_text ()
frame = NULL;
}
/* Regular test: `payload_utf8` passed, but `payload_utf8_len` == 0 */
- frame = (char*) (uintptr_t) 0xBAADF00D;
+ frame = (char *) (uintptr_t) 0xBAADF00D;
frame_len = 0x87654321;
ret = MHD_websocket_encode_text (wss,
"abc",
@@ -6130,7 +6131,7 @@ test_encodes_text ()
if ((MHD_WEBSOCKET_STATUS_OK != ret) ||
(2 != frame_len) ||
(NULL == frame) ||
- (((char*) (uintptr_t) 0xBAADF00D) == frame) ||
+ (((char *) (uintptr_t) 0xBAADF00D) == frame) ||
(0 != memcmp (frame, "\x81\x00", 2)))
{
fprintf (stderr,
@@ -6138,7 +6139,7 @@ test_encodes_text ()
(unsigned int) __LINE__);
++failed;
}
- if (((char*) (uintptr_t) 0xBAADF00D) == frame)
+ if (((char *) (uintptr_t) 0xBAADF00D) == frame)
{
frame = NULL;
}
@@ -6165,7 +6166,7 @@ test_encodes_text ()
++failed;
}
/* Fail test: `frame_len` not passed */
- frame = (char*) (uintptr_t) 0xBAADF00D;
+ frame = (char *) (uintptr_t) 0xBAADF00D;
ret = MHD_websocket_encode_text (wss,
"abc",
3,
@@ -6181,7 +6182,7 @@ test_encodes_text ()
(unsigned int) __LINE__);
++failed;
}
- if (((char*) (uintptr_t) 0xBAADF00D) == frame)
+ if (((char *) (uintptr_t) 0xBAADF00D) == frame)
{
frame = NULL;
}
@@ -6192,7 +6193,7 @@ test_encodes_text ()
}
/* Regular test: `utf8_step` passed for non-fragmentation
(is allowed and `utf8_step` will be filled then) */
- frame = (char*) (uintptr_t) 0xBAADF00D;
+ frame = (char *) (uintptr_t) 0xBAADF00D;
frame_len = 0x87654321;
utf8_step = -99;
ret = MHD_websocket_encode_text (wss,
@@ -6205,7 +6206,7 @@ test_encodes_text ()
if ((MHD_WEBSOCKET_STATUS_OK != ret) ||
(5 != frame_len) ||
(NULL == frame) ||
- (((char*) (uintptr_t) 0xBAADF00D) == frame) ||
+ (((char *) (uintptr_t) 0xBAADF00D) == frame) ||
(MHD_WEBSOCKET_UTF8STEP_NORMAL != utf8_step) ||
(0 != memcmp (frame, "\x81\x03" "abc", 5)))
{
@@ -6214,7 +6215,7 @@ test_encodes_text ()
(unsigned int) __LINE__);
++failed;
}
- if (((char*) (uintptr_t) 0xBAADF00D) == frame)
+ if (((char *) (uintptr_t) 0xBAADF00D) == frame)
{
frame = NULL;
}
@@ -6225,7 +6226,7 @@ test_encodes_text ()
}
/* Fail test: `utf8_step` passed for non-fragmentation with invalid UTF-8
(is allowed and `utf8_step` will be filled then) */
- frame = (char*) (uintptr_t) 0xBAADF00D;
+ frame = (char *) (uintptr_t) 0xBAADF00D;
frame_len = 0x87654321;
utf8_step = -99;
ret = MHD_websocket_encode_text (wss,
@@ -6245,7 +6246,7 @@ test_encodes_text ()
(unsigned int) __LINE__);
++failed;
}
- if (((char*) (uintptr_t) 0xBAADF00D) == frame)
+ if (((char *) (uintptr_t) 0xBAADF00D) == frame)
{
frame = NULL;
}
@@ -6255,7 +6256,7 @@ test_encodes_text ()
frame = NULL;
}
/* Fail test: `utf8_step` not passed for fragmentation #1 */
- frame = (char*) (uintptr_t) 0xBAADF00D;
+ frame = (char *) (uintptr_t) 0xBAADF00D;
frame_len = 0x87654321;
ret = MHD_websocket_encode_text (wss,
"abc",
@@ -6273,7 +6274,7 @@ test_encodes_text ()
(unsigned int) __LINE__);
++failed;
}
- if (((char*) (uintptr_t) 0xBAADF00D) == frame)
+ if (((char *) (uintptr_t) 0xBAADF00D) == frame)
{
frame = NULL;
}
@@ -6283,7 +6284,7 @@ test_encodes_text ()
frame = NULL;
}
/* Fail test: `utf8_step` not passed for fragmentation #2 */
- frame = (char*) (uintptr_t) 0xBAADF00D;
+ frame = (char *) (uintptr_t) 0xBAADF00D;
frame_len = 0x87654321;
ret = MHD_websocket_encode_text (wss,
"abc",
@@ -6301,7 +6302,7 @@ test_encodes_text ()
(unsigned int) __LINE__);
++failed;
}
- if (((char*) (uintptr_t) 0xBAADF00D) == frame)
+ if (((char *) (uintptr_t) 0xBAADF00D) == frame)
{
frame = NULL;
}
@@ -6311,7 +6312,7 @@ test_encodes_text ()
frame = NULL;
}
/* Fail test: `utf8_step` not passed for fragmentation #3 */
- frame = (char*) (uintptr_t) 0xBAADF00D;
+ frame = (char *) (uintptr_t) 0xBAADF00D;
frame_len = 0x87654321;
ret = MHD_websocket_encode_text (wss,
"abc",
@@ -6329,7 +6330,7 @@ test_encodes_text ()
(unsigned int) __LINE__);
++failed;
}
- if (((char*) (uintptr_t) 0xBAADF00D) == frame)
+ if (((char *) (uintptr_t) 0xBAADF00D) == frame)
{
frame = NULL;
}
@@ -6339,7 +6340,7 @@ test_encodes_text ()
frame = NULL;
}
/* Regular test: `utf8_step` passed for fragmentation #1 */
- frame = (char*) (uintptr_t) 0xBAADF00D;
+ frame = (char *) (uintptr_t) 0xBAADF00D;
frame_len = 0x87654321;
utf8_step = -99;
ret = MHD_websocket_encode_text (wss,
@@ -6352,7 +6353,7 @@ test_encodes_text ()
if ((MHD_WEBSOCKET_STATUS_OK != ret) ||
(5 != frame_len) ||
(NULL == frame) ||
- (((char*) (uintptr_t) 0xBAADF00D) == frame) ||
+ (((char *) (uintptr_t) 0xBAADF00D) == frame) ||
(MHD_WEBSOCKET_UTF8STEP_NORMAL != utf8_step) ||
(0 != memcmp (frame, "\x01\x03" "abc", 5)))
{
@@ -6361,7 +6362,7 @@ test_encodes_text ()
(unsigned int) __LINE__);
++failed;
}
- if (((char*) (uintptr_t) 0xBAADF00D) == frame)
+ if (((char *) (uintptr_t) 0xBAADF00D) == frame)
{
frame = NULL;
}
@@ -6371,7 +6372,7 @@ test_encodes_text ()
frame = NULL;
}
/* Regular test: `utf8_step` passed for fragmentation #2 */
- frame = (char*) (uintptr_t) 0xBAADF00D;
+ frame = (char *) (uintptr_t) 0xBAADF00D;
frame_len = 0x87654321;
utf8_step = MHD_WEBSOCKET_UTF8STEP_NORMAL;
ret = MHD_websocket_encode_text (wss,
@@ -6384,7 +6385,7 @@ test_encodes_text ()
if ((MHD_WEBSOCKET_STATUS_OK != ret) ||
(5 != frame_len) ||
(NULL == frame) ||
- (((char*) (uintptr_t) 0xBAADF00D) == frame) ||
+ (((char *) (uintptr_t) 0xBAADF00D) == frame) ||
(MHD_WEBSOCKET_UTF8STEP_NORMAL != utf8_step) ||
(0 != memcmp (frame, "\x00\x03" "abc", 5)))
{
@@ -6393,7 +6394,7 @@ test_encodes_text ()
(unsigned int) __LINE__);
++failed;
}
- if (((char*) (uintptr_t) 0xBAADF00D) == frame)
+ if (((char *) (uintptr_t) 0xBAADF00D) == frame)
{
frame = NULL;
}
@@ -6403,7 +6404,7 @@ test_encodes_text ()
frame = NULL;
}
/* Regular test: `utf8_step` passed for fragmentation #3 */
- frame = (char*) (uintptr_t) 0xBAADF00D;
+ frame = (char *) (uintptr_t) 0xBAADF00D;
frame_len = 0x87654321;
utf8_step = MHD_WEBSOCKET_UTF8STEP_NORMAL;
ret = MHD_websocket_encode_text (wss,
@@ -6416,7 +6417,7 @@ test_encodes_text ()
if ((MHD_WEBSOCKET_STATUS_OK != ret) ||
(5 != frame_len) ||
(NULL == frame) ||
- (((char*) (uintptr_t) 0xBAADF00D) == frame) ||
+ (((char *) (uintptr_t) 0xBAADF00D) == frame) ||
(MHD_WEBSOCKET_UTF8STEP_NORMAL != utf8_step) ||
(0 != memcmp (frame, "\x80\x03" "abc", 5)))
{
@@ -6425,7 +6426,7 @@ test_encodes_text ()
(unsigned int) __LINE__);
++failed;
}
- if (((char*) (uintptr_t) 0xBAADF00D) == frame)
+ if (((char *) (uintptr_t) 0xBAADF00D) == frame)
{
frame = NULL;
}
@@ -6435,7 +6436,7 @@ test_encodes_text ()
frame = NULL;
}
/* Fail test: `fragmentation` has an invalid value */
- frame = (char*) (uintptr_t) 0xBAADF00D;
+ frame = (char *) (uintptr_t) 0xBAADF00D;
frame_len = 0x87654321;
utf8_step = -99;
ret = MHD_websocket_encode_text (wss,
@@ -6455,7 +6456,7 @@ test_encodes_text ()
(unsigned int) __LINE__);
++failed;
}
- if (((char*) (uintptr_t) 0xBAADF00D) == frame)
+ if (((char *) (uintptr_t) 0xBAADF00D) == frame)
{
frame = NULL;
}
@@ -6471,7 +6472,7 @@ test_encodes_text ()
------------------------------------------------------------------------------
*/
{
- struct MHD_WebSocketStream*wsx;
+ struct MHD_WebSocketStream *wsx;
if (MHD_WEBSOCKET_STATUS_OK == MHD_websocket_stream_init2 (&wsx,
MHD_WEBSOCKET_FLAG_SERVER,
0,
@@ -6560,11 +6561,11 @@ int
test_encodes_binary ()
{
int failed = 0;
- struct MHD_WebSocketStream*wss;
- struct MHD_WebSocketStream*wsc;
+ struct MHD_WebSocketStream *wss;
+ struct MHD_WebSocketStream *wsc;
int ret;
char *buf1 = NULL, *buf2 = NULL;
- char*frame = NULL;
+ char *frame = NULL;
size_t frame_len = 0;
if (MHD_WEBSOCKET_STATUS_OK != MHD_websocket_stream_init2 (&wsc,
@@ -7016,7 +7017,7 @@ test_encodes_binary ()
------------------------------------------------------------------------------
*/
/* Fail test: `ws` not passed */
- frame = (char*) (uintptr_t) 0xBAADF00D;
+ frame = (char *) (uintptr_t) 0xBAADF00D;
frame_len = 0x87654321;
ret = MHD_websocket_encode_binary (NULL,
"abc",
@@ -7033,7 +7034,7 @@ test_encodes_binary ()
(unsigned int) __LINE__);
++failed;
}
- if (((char*) (uintptr_t) 0xBAADF00D) == frame)
+ if (((char *) (uintptr_t) 0xBAADF00D) == frame)
{
frame = NULL;
}
@@ -7043,7 +7044,7 @@ test_encodes_binary ()
frame = NULL;
}
/* Fail test: `payload` not passed, but `payload_len` != 0 */
- frame = (char*) (uintptr_t) 0xBAADF00D;
+ frame = (char *) (uintptr_t) 0xBAADF00D;
frame_len = 0x87654321;
ret = MHD_websocket_encode_binary (wss,
NULL,
@@ -7060,7 +7061,7 @@ test_encodes_binary ()
(unsigned int) __LINE__);
++failed;
}
- if (((char*) (uintptr_t) 0xBAADF00D) == frame)
+ if (((char *) (uintptr_t) 0xBAADF00D) == frame)
{
frame = NULL;
}
@@ -7070,7 +7071,7 @@ test_encodes_binary ()
frame = NULL;
}
/* Regular test: `payload` passed, but `payload_len` == 0 */
- frame = (char*) (uintptr_t) 0xBAADF00D;
+ frame = (char *) (uintptr_t) 0xBAADF00D;
frame_len = 0x87654321;
ret = MHD_websocket_encode_binary (wss,
"abc",
@@ -7081,7 +7082,7 @@ test_encodes_binary ()
if ((MHD_WEBSOCKET_STATUS_OK != ret) ||
(2 != frame_len) ||
(NULL == frame) ||
- (((char*) (uintptr_t) 0xBAADF00D) == frame) ||
+ (((char *) (uintptr_t) 0xBAADF00D) == frame) ||
(0 != memcmp (frame, "\x82\x00", 2)))
{
fprintf (stderr,
@@ -7089,7 +7090,7 @@ test_encodes_binary ()
(unsigned int) __LINE__);
++failed;
}
- if (((char*) (uintptr_t) 0xBAADF00D) == frame)
+ if (((char *) (uintptr_t) 0xBAADF00D) == frame)
{
frame = NULL;
}
@@ -7116,7 +7117,7 @@ test_encodes_binary ()
++failed;
}
/* Fail test: `frame_len` not passed */
- frame = (char*) (uintptr_t) 0xBAADF00D;
+ frame = (char *) (uintptr_t) 0xBAADF00D;
ret = MHD_websocket_encode_binary (wss,
"abc",
3,
@@ -7131,7 +7132,7 @@ test_encodes_binary ()
(unsigned int) __LINE__);
++failed;
}
- if (((char*) (uintptr_t) 0xBAADF00D) == frame)
+ if (((char *) (uintptr_t) 0xBAADF00D) == frame)
{
frame = NULL;
}
@@ -7141,7 +7142,7 @@ test_encodes_binary ()
frame = NULL;
}
/* Fail test: `fragmentation` has an invalid value */
- frame = (char*) (uintptr_t) 0xBAADF00D;
+ frame = (char *) (uintptr_t) 0xBAADF00D;
frame_len = 0x87654321;
ret = MHD_websocket_encode_binary (wss,
"abc",
@@ -7158,7 +7159,7 @@ test_encodes_binary ()
(unsigned int) __LINE__);
++failed;
}
- if (((char*) (uintptr_t) 0xBAADF00D) == frame)
+ if (((char *) (uintptr_t) 0xBAADF00D) == frame)
{
frame = NULL;
}
@@ -7174,7 +7175,7 @@ test_encodes_binary ()
------------------------------------------------------------------------------
*/
{
- struct MHD_WebSocketStream*wsx;
+ struct MHD_WebSocketStream *wsx;
if (MHD_WEBSOCKET_STATUS_OK == MHD_websocket_stream_init2 (&wsx,
MHD_WEBSOCKET_FLAG_SERVER,
0,
@@ -7261,11 +7262,11 @@ int
test_encodes_close ()
{
int failed = 0;
- struct MHD_WebSocketStream*wss;
- struct MHD_WebSocketStream*wsc;
+ struct MHD_WebSocketStream *wss;
+ struct MHD_WebSocketStream *wsc;
int ret;
char *buf1 = NULL, *buf2 = NULL;
- char*frame = NULL;
+ char *frame = NULL;
size_t frame_len = 0;
if (MHD_WEBSOCKET_STATUS_OK != MHD_websocket_stream_init2 (&wsc,
@@ -7685,7 +7686,7 @@ test_encodes_close ()
------------------------------------------------------------------------------
*/
/* Fail test: `ws` not passed */
- frame = (char*) (uintptr_t) 0xBAADF00D;
+ frame = (char *) (uintptr_t) 0xBAADF00D;
frame_len = 0x87654321;
ret = MHD_websocket_encode_close (NULL,
MHD_WEBSOCKET_CLOSEREASON_REGULAR,
@@ -7702,7 +7703,7 @@ test_encodes_close ()
(unsigned int) __LINE__);
++failed;
}
- if (((char*) (uintptr_t) 0xBAADF00D) == frame)
+ if (((char *) (uintptr_t) 0xBAADF00D) == frame)
{
frame = NULL;
}
@@ -7712,7 +7713,7 @@ test_encodes_close ()
frame = NULL;
}
/* Fail test: `payload` not passed, but `payload_len` != 0 */
- frame = (char*) (uintptr_t) 0xBAADF00D;
+ frame = (char *) (uintptr_t) 0xBAADF00D;
frame_len = 0x87654321;
ret = MHD_websocket_encode_close (wss,
MHD_WEBSOCKET_CLOSEREASON_REGULAR,
@@ -7729,7 +7730,7 @@ test_encodes_close ()
(unsigned int) __LINE__);
++failed;
}
- if (((char*) (uintptr_t) 0xBAADF00D) == frame)
+ if (((char *) (uintptr_t) 0xBAADF00D) == frame)
{
frame = NULL;
}
@@ -7739,7 +7740,7 @@ test_encodes_close ()
frame = NULL;
}
/* Regular test: `payload` passed, but `payload_len` == 0 */
- frame = (char*) (uintptr_t) 0xBAADF00D;
+ frame = (char *) (uintptr_t) 0xBAADF00D;
frame_len = 0x87654321;
ret = MHD_websocket_encode_close (wss,
MHD_WEBSOCKET_CLOSEREASON_REGULAR,
@@ -7750,7 +7751,7 @@ test_encodes_close ()
if ((MHD_WEBSOCKET_STATUS_OK != ret) ||
(4 != frame_len) ||
(NULL == frame) ||
- (((char*) (uintptr_t) 0xBAADF00D) == frame) ||
+ (((char *) (uintptr_t) 0xBAADF00D) == frame) ||
(0 != memcmp (frame, "\x88\x02\x03\xE8", 4)))
{
fprintf (stderr,
@@ -7758,7 +7759,7 @@ test_encodes_close ()
(unsigned int) __LINE__);
++failed;
}
- if (((char*) (uintptr_t) 0xBAADF00D) == frame)
+ if (((char *) (uintptr_t) 0xBAADF00D) == frame)
{
frame = NULL;
}
@@ -7785,7 +7786,7 @@ test_encodes_close ()
++failed;
}
/* Fail test: `frame_len` not passed */
- frame = (char*) (uintptr_t) 0xBAADF00D;
+ frame = (char *) (uintptr_t) 0xBAADF00D;
ret = MHD_websocket_encode_close (wss,
MHD_WEBSOCKET_CLOSEREASON_REGULAR,
"abc",
@@ -7801,7 +7802,7 @@ test_encodes_close ()
(unsigned int) __LINE__);
++failed;
}
- if (((char*) (uintptr_t) 0xBAADF00D) == frame)
+ if (((char *) (uintptr_t) 0xBAADF00D) == frame)
{
frame = NULL;
}
@@ -7811,7 +7812,7 @@ test_encodes_close ()
frame = NULL;
}
/* Fail test: no reason code passed, but reason text */
- frame = (char*) (uintptr_t) 0xBAADF00D;
+ frame = (char *) (uintptr_t) 0xBAADF00D;
frame_len = 0x87654321;
ret = MHD_websocket_encode_close (wss,
MHD_WEBSOCKET_CLOSEREASON_NO_REASON,
@@ -7828,7 +7829,7 @@ test_encodes_close ()
(unsigned int) __LINE__);
++failed;
}
- if (((char*) (uintptr_t) 0xBAADF00D) == frame)
+ if (((char *) (uintptr_t) 0xBAADF00D) == frame)
{
frame = NULL;
}
@@ -7838,7 +7839,7 @@ test_encodes_close ()
frame = NULL;
}
/* Edge test (fail): Invalid reason code */
- frame = (char*) (uintptr_t) 0xBAADF00D;
+ frame = (char *) (uintptr_t) 0xBAADF00D;
frame_len = 0x87654321;
ret = MHD_websocket_encode_close (wss,
1,
@@ -7855,7 +7856,7 @@ test_encodes_close ()
(unsigned int) __LINE__);
++failed;
}
- if (((char*) (uintptr_t) 0xBAADF00D) == frame)
+ if (((char *) (uintptr_t) 0xBAADF00D) == frame)
{
frame = NULL;
}
@@ -7865,7 +7866,7 @@ test_encodes_close ()
frame = NULL;
}
/* Edge test (fail): Invalid reason code */
- frame = (char*) (uintptr_t) 0xBAADF00D;
+ frame = (char *) (uintptr_t) 0xBAADF00D;
frame_len = 0x87654321;
ret = MHD_websocket_encode_close (wss,
999,
@@ -7882,7 +7883,7 @@ test_encodes_close ()
(unsigned int) __LINE__);
++failed;
}
- if (((char*) (uintptr_t) 0xBAADF00D) == frame)
+ if (((char *) (uintptr_t) 0xBAADF00D) == frame)
{
frame = NULL;
}
@@ -7892,7 +7893,7 @@ test_encodes_close ()
frame = NULL;
}
/* Regular test: Custom reason code */
- frame = (char*) (uintptr_t) 0xBAADF00D;
+ frame = (char *) (uintptr_t) 0xBAADF00D;
frame_len = 0x87654321;
ret = MHD_websocket_encode_close (wss,
2000,
@@ -7903,7 +7904,7 @@ test_encodes_close ()
if ((MHD_WEBSOCKET_STATUS_OK != ret) ||
(7 != frame_len) ||
(NULL == frame) ||
- (((char*) (uintptr_t) 0xBAADF00D) == frame) ||
+ (((char *) (uintptr_t) 0xBAADF00D) == frame) ||
(0 != memcmp (frame, "\x88\x05\x07\xD0" "abc", 7)))
{
fprintf (stderr,
@@ -7911,7 +7912,7 @@ test_encodes_close ()
(unsigned int) __LINE__);
++failed;
}
- if (((char*) (uintptr_t) 0xBAADF00D) == frame)
+ if (((char *) (uintptr_t) 0xBAADF00D) == frame)
{
frame = NULL;
}
@@ -7927,7 +7928,7 @@ test_encodes_close ()
------------------------------------------------------------------------------
*/
{
- struct MHD_WebSocketStream*wsx;
+ struct MHD_WebSocketStream *wsx;
if (MHD_WEBSOCKET_STATUS_OK == MHD_websocket_stream_init2 (&wsx,
MHD_WEBSOCKET_FLAG_SERVER,
0,
@@ -8014,11 +8015,11 @@ int
test_encodes_ping ()
{
int failed = 0;
- struct MHD_WebSocketStream*wss;
- struct MHD_WebSocketStream*wsc;
+ struct MHD_WebSocketStream *wss;
+ struct MHD_WebSocketStream *wsc;
int ret;
char *buf1 = NULL, *buf2 = NULL;
- char*frame = NULL;
+ char *frame = NULL;
size_t frame_len = 0;
if (MHD_WEBSOCKET_STATUS_OK != MHD_websocket_stream_init2 (&wsc,
@@ -8342,7 +8343,7 @@ test_encodes_ping ()
------------------------------------------------------------------------------
*/
/* Fail test: `ws` not passed */
- frame = (char*) (uintptr_t) 0xBAADF00D;
+ frame = (char *) (uintptr_t) 0xBAADF00D;
frame_len = 0x87654321;
ret = MHD_websocket_encode_ping (NULL,
"abc",
@@ -8358,7 +8359,7 @@ test_encodes_ping ()
(unsigned int) __LINE__);
++failed;
}
- if (((char*) (uintptr_t) 0xBAADF00D) == frame)
+ if (((char *) (uintptr_t) 0xBAADF00D) == frame)
{
frame = NULL;
}
@@ -8368,7 +8369,7 @@ test_encodes_ping ()
frame = NULL;
}
/* Fail test: `payload` not passed, but `payload_len` != 0 */
- frame = (char*) (uintptr_t) 0xBAADF00D;
+ frame = (char *) (uintptr_t) 0xBAADF00D;
frame_len = 0x87654321;
ret = MHD_websocket_encode_ping (wss,
NULL,
@@ -8384,7 +8385,7 @@ test_encodes_ping ()
(unsigned int) __LINE__);
++failed;
}
- if (((char*) (uintptr_t) 0xBAADF00D) == frame)
+ if (((char *) (uintptr_t) 0xBAADF00D) == frame)
{
frame = NULL;
}
@@ -8394,7 +8395,7 @@ test_encodes_ping ()
frame = NULL;
}
/* Regular test: `payload` passed, but `payload_len` == 0 */
- frame = (char*) (uintptr_t) 0xBAADF00D;
+ frame = (char *) (uintptr_t) 0xBAADF00D;
frame_len = 0x87654321;
ret = MHD_websocket_encode_ping (wss,
"abc",
@@ -8404,7 +8405,7 @@ test_encodes_ping ()
if ((MHD_WEBSOCKET_STATUS_OK != ret) ||
(2 != frame_len) ||
(NULL == frame) ||
- (((char*) (uintptr_t) 0xBAADF00D) == frame) ||
+ (((char *) (uintptr_t) 0xBAADF00D) == frame) ||
(0 != memcmp (frame, "\x89\x00", 2)))
{
fprintf (stderr,
@@ -8412,7 +8413,7 @@ test_encodes_ping ()
(unsigned int) __LINE__);
++failed;
}
- if (((char*) (uintptr_t) 0xBAADF00D) == frame)
+ if (((char *) (uintptr_t) 0xBAADF00D) == frame)
{
frame = NULL;
}
@@ -8437,7 +8438,7 @@ test_encodes_ping ()
++failed;
}
/* Fail test: `frame_len` not passed */
- frame = (char*) (uintptr_t) 0xBAADF00D;
+ frame = (char *) (uintptr_t) 0xBAADF00D;
ret = MHD_websocket_encode_ping (wss,
"abc",
3,
@@ -8451,7 +8452,7 @@ test_encodes_ping ()
(unsigned int) __LINE__);
++failed;
}
- if (((char*) (uintptr_t) 0xBAADF00D) == frame)
+ if (((char *) (uintptr_t) 0xBAADF00D) == frame)
{
frame = NULL;
}
@@ -8467,7 +8468,7 @@ test_encodes_ping ()
------------------------------------------------------------------------------
*/
{
- struct MHD_WebSocketStream*wsx;
+ struct MHD_WebSocketStream *wsx;
if (MHD_WEBSOCKET_STATUS_OK == MHD_websocket_stream_init2 (&wsx,
MHD_WEBSOCKET_FLAG_SERVER,
0,
@@ -8552,11 +8553,11 @@ int
test_encodes_pong ()
{
int failed = 0;
- struct MHD_WebSocketStream*wss;
- struct MHD_WebSocketStream*wsc;
+ struct MHD_WebSocketStream *wss;
+ struct MHD_WebSocketStream *wsc;
int ret;
char *buf1 = NULL, *buf2 = NULL;
- char*frame = NULL;
+ char *frame = NULL;
size_t frame_len = 0;
if (MHD_WEBSOCKET_STATUS_OK != MHD_websocket_stream_init2 (&wsc,
@@ -8880,7 +8881,7 @@ test_encodes_pong ()
------------------------------------------------------------------------------
*/
/* Fail test: `ws` not passed */
- frame = (char*) (uintptr_t) 0xBAADF00D;
+ frame = (char *) (uintptr_t) 0xBAADF00D;
frame_len = 0x87654321;
ret = MHD_websocket_encode_pong (NULL,
"abc",
@@ -8896,7 +8897,7 @@ test_encodes_pong ()
(unsigned int) __LINE__);
++failed;
}
- if (((char*) (uintptr_t) 0xBAADF00D) == frame)
+ if (((char *) (uintptr_t) 0xBAADF00D) == frame)
{
frame = NULL;
}
@@ -8906,7 +8907,7 @@ test_encodes_pong ()
frame = NULL;
}
/* Fail test: `payload` not passed, but `payload_len` != 0 */
- frame = (char*) (uintptr_t) 0xBAADF00D;
+ frame = (char *) (uintptr_t) 0xBAADF00D;
frame_len = 0x87654321;
ret = MHD_websocket_encode_pong (wss,
NULL,
@@ -8922,7 +8923,7 @@ test_encodes_pong ()
(unsigned int) __LINE__);
++failed;
}
- if (((char*) (uintptr_t) 0xBAADF00D) == frame)
+ if (((char *) (uintptr_t) 0xBAADF00D) == frame)
{
frame = NULL;
}
@@ -8932,7 +8933,7 @@ test_encodes_pong ()
frame = NULL;
}
/* Regular test: `payload` passed, but `payload_len` == 0 */
- frame = (char*) (uintptr_t) 0xBAADF00D;
+ frame = (char *) (uintptr_t) 0xBAADF00D;
frame_len = 0x87654321;
ret = MHD_websocket_encode_pong (wss,
"abc",
@@ -8942,7 +8943,7 @@ test_encodes_pong ()
if ((MHD_WEBSOCKET_STATUS_OK != ret) ||
(2 != frame_len) ||
(NULL == frame) ||
- (((char*) (uintptr_t) 0xBAADF00D) == frame) ||
+ (((char *) (uintptr_t) 0xBAADF00D) == frame) ||
(0 != memcmp (frame, "\x8A\x00", 2)))
{
fprintf (stderr,
@@ -8950,7 +8951,7 @@ test_encodes_pong ()
(unsigned int) __LINE__);
++failed;
}
- if (((char*) (uintptr_t) 0xBAADF00D) == frame)
+ if (((char *) (uintptr_t) 0xBAADF00D) == frame)
{
frame = NULL;
}
@@ -8975,7 +8976,7 @@ test_encodes_pong ()
++failed;
}
/* Fail test: `frame_len` not passed */
- frame = (char*) (uintptr_t) 0xBAADF00D;
+ frame = (char *) (uintptr_t) 0xBAADF00D;
ret = MHD_websocket_encode_pong (wss,
"abc",
3,
@@ -8989,7 +8990,7 @@ test_encodes_pong ()
(unsigned int) __LINE__);
++failed;
}
- if (((char*) (uintptr_t) 0xBAADF00D) == frame)
+ if (((char *) (uintptr_t) 0xBAADF00D) == frame)
{
frame = NULL;
}
@@ -9005,7 +9006,7 @@ test_encodes_pong ()
------------------------------------------------------------------------------
*/
{
- struct MHD_WebSocketStream*wsx;
+ struct MHD_WebSocketStream *wsx;
if (MHD_WEBSOCKET_STATUS_OK == MHD_websocket_stream_init2 (&wsx,
MHD_WEBSOCKET_FLAG_SERVER,
0,
@@ -9090,9 +9091,9 @@ int
test_split_close_reason ()
{
int failed = 0;
- const char*payload;
+ const char *payload;
unsigned short reason_code;
- const char*reason_utf8;
+ const char *reason_utf8;
size_t reason_utf8_len;
int ret;
@@ -9103,7 +9104,7 @@ test_split_close_reason ()
*/
/* Regular test: Reason code + Reason text */
reason_code = 9999;
- reason_utf8 = (const char*) (intptr_t) 0xBAADF00D;
+ reason_utf8 = (const char *) (intptr_t) 0xBAADF00D;
reason_utf8_len = 12345;
payload = "\x03\xE8" "abc";
ret = MHD_websocket_split_close_reason (payload,
@@ -9123,7 +9124,7 @@ test_split_close_reason ()
}
/* Regular test: Reason code */
reason_code = 9999;
- reason_utf8 = (const char*) (intptr_t) 0xBAADF00D;
+ reason_utf8 = (const char *) (intptr_t) 0xBAADF00D;
reason_utf8_len = 12345;
payload = "\x03\xE8";
ret = MHD_websocket_split_close_reason (payload,
@@ -9143,7 +9144,7 @@ test_split_close_reason ()
}
/* Regular test: No payload */
reason_code = 9999;
- reason_utf8 = (const char*) (intptr_t) 0xBAADF00D;
+ reason_utf8 = (const char *) (intptr_t) 0xBAADF00D;
reason_utf8_len = 12345;
payload = NULL;
ret = MHD_websocket_split_close_reason (payload,
@@ -9163,7 +9164,7 @@ test_split_close_reason ()
}
/* Regular test: `payload` is not NULL given, but `payload_len` == 0 */
reason_code = 9999;
- reason_utf8 = (const char*) (intptr_t) 0xBAADF00D;
+ reason_utf8 = (const char *) (intptr_t) 0xBAADF00D;
reason_utf8_len = 12345;
payload = "abc";
ret = MHD_websocket_split_close_reason (payload,
@@ -9189,7 +9190,7 @@ test_split_close_reason ()
*/
/* Fail test: `payload` not passed, but `payload_len` != 0 */
reason_code = 9999;
- reason_utf8 = (const char*) (intptr_t) 0xBAADF00D;
+ reason_utf8 = (const char *) (intptr_t) 0xBAADF00D;
reason_utf8_len = 12345;
payload = NULL;
ret = MHD_websocket_split_close_reason (payload,
@@ -9208,7 +9209,7 @@ test_split_close_reason ()
++failed;
}
/* Regular test: `reason_code` not passed */
- reason_utf8 = (const char*) (intptr_t) 0xBAADF00D;
+ reason_utf8 = (const char *) (intptr_t) 0xBAADF00D;
reason_utf8_len = 12345;
payload = "\x03\xE8" "abc";
ret = MHD_websocket_split_close_reason (payload,
@@ -9245,7 +9246,7 @@ test_split_close_reason ()
}
/* Regular test: `reason_utf8_len` not passed */
reason_code = 9999;
- reason_utf8 = (const char*) (intptr_t) 0xBAADF00D;
+ reason_utf8 = (const char *) (intptr_t) 0xBAADF00D;
payload = "\x03\xE8" "abc";
ret = MHD_websocket_split_close_reason (payload,
5,
@@ -9600,7 +9601,8 @@ test_check_connection_header ()
++failed;
}
/* Edge test (success): Transfer-Encoding,Upgrade,keep-alive */
- ret = MHD_websocket_check_connection_header
("Transfer-Encoding,Upgrade,keep-alive");
+ ret = MHD_websocket_check_connection_header (
+ "Transfer-Encoding,Upgrade,keep-alive");
if (MHD_WEBSOCKET_STATUS_OK != ret)
{
fprintf (stderr,
@@ -9609,7 +9611,8 @@ test_check_connection_header ()
++failed;
}
/* Edge test (success): Transfer-Encoding , Upgrade , keep-alive */
- ret = MHD_websocket_check_connection_header ("Transfer-Encoding , Upgrade
, keep-alive");
+ ret = MHD_websocket_check_connection_header (
+ "Transfer-Encoding , Upgrade , keep-alive");
if (MHD_WEBSOCKET_STATUS_OK != ret)
{
fprintf (stderr,
@@ -9636,7 +9639,8 @@ test_check_connection_header ()
++failed;
}
/* Edge test (success): All allowed token characters, then upgrade token */
- ret = MHD_websocket_check_connection_header
("!#$%&'*+-.^_`|~0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz,Upgrade");
+ ret = MHD_websocket_check_connection_header (
+
"!#$%&'*+-.^_`|~0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz,Upgrade");
if (MHD_WEBSOCKET_STATUS_OK != ret)
{
fprintf (stderr,
@@ -9835,7 +9839,8 @@ test_check_upgrade_header ()
++failed;
}
/* Edge test (success): All allowed token characters plus /, then websocket
keyowrd */
- ret = MHD_websocket_check_upgrade_header
("!#$%&'*+-.^_`|~0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz/,websocket");
+ ret = MHD_websocket_check_upgrade_header (
+
"!#$%&'*+-.^_`|~0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz/,websocket");
if (MHD_WEBSOCKET_STATUS_OK != ret)
{
fprintf (stderr,
diff --git a/src/microhttpd_ws/test_websocket_browser.c
b/src/microhttpd_ws/test_websocket_browser.c
index dfbcd116..72354257 100644
--- a/src/microhttpd_ws/test_websocket_browser.c
+++ b/src/microhttpd_ws/test_websocket_browser.c
@@ -187,6 +187,7 @@ static void
send_all (MHD_socket fd,
const char *buf,
size_t len);
+
static void
make_blocking (MHD_socket fd);
@@ -203,7 +204,7 @@ upgrade_handler (void *cls,
make_blocking (fd);
/* create a websocket stream for this connection */
- struct MHD_WebSocketStream* ws;
+ struct MHD_WebSocketStream *ws;
int result = MHD_websocket_stream_init (&ws,
0,
0);
@@ -253,7 +254,8 @@ upgrade_handler (void *cls,
if (0 > status)
{
/* an error occurred and the connection must be closed */
- printf ("Decoding failed: status=%d, passed=%u\n", status, ((size_t)
got) - buf_offset);
+ printf ("Decoding failed: status=%d, passed=%u\n", status,
+ ((size_t) got) - buf_offset);
if (NULL != payload_data)
{
MHD_websocket_free (ws, payload_data);
@@ -266,13 +268,15 @@ upgrade_handler (void *cls,
if (0 < status)
{
/* the frame is complete */
- printf ("Decoding succeeded: type=%d, passed=%u, parsed=%u,
payload_len=%d\n", status, ((size_t) got) - buf_offset, new_offset,
payload_len);
+ printf (
+ "Decoding succeeded: type=%d, passed=%u, parsed=%u,
payload_len=%d\n",
+ status, ((size_t) got) - buf_offset, new_offset, payload_len);
switch (status)
{
case MHD_WEBSOCKET_STATUS_TEXT_FRAME:
case MHD_WEBSOCKET_STATUS_BINARY_FRAME:
/* The client has sent some data. */
- if (NULL != payload_data || 0 == payload_len)
+ if ((NULL != payload_data) || (0 == payload_len))
{
/* Send the received data back to the client */
if (MHD_WEBSOCKET_STATUS_TEXT_FRAME == status)
@@ -288,11 +292,11 @@ upgrade_handler (void *cls,
else
{
result = MHD_websocket_encode_binary (ws,
- payload_data,
- payload_len,
- 0,
- &frame_data,
- &frame_len);
+ payload_data,
+ payload_len,
+ 0,
+ &frame_data,
+ &frame_len);
}
if (0 == result)
{
@@ -336,6 +340,7 @@ upgrade_handler (void *cls,
MHD_UPGRADE_ACTION_CLOSE);
}
+
/* This helper function is used for the case that
* we need to resend some data
*/
@@ -367,6 +372,7 @@ send_all (MHD_socket fd,
}
}
+
/* This helper function contains operating-system-dependent code and
* is used to make a socket blocking.
*/
@@ -389,6 +395,7 @@ make_blocking (MHD_socket fd)
#endif
}
+
static enum MHD_Result
access_handler (void *cls,
struct MHD_Connection *connection,
@@ -421,9 +428,9 @@ access_handler (void *cls,
{
/* Default page for visiting the server */
struct MHD_Response *response = MHD_create_response_from_buffer (
- strlen (PAGE),
- PAGE,
- MHD_RESPMEM_PERSISTENT);
+ strlen (PAGE),
+ PAGE,
+ MHD_RESPMEM_PERSISTENT);
ret = MHD_queue_response (connection,
MHD_HTTP_OK,
response);
@@ -435,9 +442,9 @@ access_handler (void *cls,
fprintf (stderr, "Error in test (%s)\n", url + 7);
struct MHD_Response *response = MHD_create_response_from_buffer (
- 0,
- "",
- MHD_RESPMEM_PERSISTENT);
+ 0,
+ "",
+ MHD_RESPMEM_PERSISTENT);
ret = MHD_queue_response (connection,
MHD_HTTP_OK,
response);
@@ -446,7 +453,7 @@ access_handler (void *cls,
else if (0 == strcmp (url, "/websocket"))
{
char is_valid = 1;
- const char* value = NULL;
+ const char *value = NULL;
char sec_websocket_accept[29];
if (0 != MHD_websocket_check_http_version (version))
@@ -504,10 +511,10 @@ access_handler (void *cls,
else
{
/* return error page */
- struct MHD_Response*response = MHD_create_response_from_buffer (
- strlen (PAGE_INVALID_WEBSOCKET_REQUEST),
- PAGE_INVALID_WEBSOCKET_REQUEST,
- MHD_RESPMEM_PERSISTENT);
+ struct MHD_Response *response = MHD_create_response_from_buffer (
+ strlen (PAGE_INVALID_WEBSOCKET_REQUEST),
+ PAGE_INVALID_WEBSOCKET_REQUEST,
+ MHD_RESPMEM_PERSISTENT);
ret = MHD_queue_response (connection,
MHD_HTTP_BAD_REQUEST,
response);
@@ -516,10 +523,10 @@ access_handler (void *cls,
}
else
{
- struct MHD_Response*response = MHD_create_response_from_buffer (
- strlen (PAGE_NOT_FOUND),
- PAGE_NOT_FOUND,
- MHD_RESPMEM_PERSISTENT);
+ struct MHD_Response *response = MHD_create_response_from_buffer (
+ strlen (PAGE_NOT_FOUND),
+ PAGE_NOT_FOUND,
+ MHD_RESPMEM_PERSISTENT);
ret = MHD_queue_response (connection,
MHD_HTTP_NOT_FOUND,
response);
@@ -529,6 +536,7 @@ access_handler (void *cls,
return ret;
}
+
int
main (int argc,
char *const *argv)
@@ -537,10 +545,10 @@ main (int argc,
(void) argv; /* Unused. Silent compiler warning. */
struct MHD_Daemon *daemon;
- daemon = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD |
- MHD_USE_THREAD_PER_CONNECTION |
- MHD_ALLOW_UPGRADE |
- MHD_USE_ERROR_LOG,
+ daemon = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD
+ | MHD_USE_THREAD_PER_CONNECTION
+ | MHD_ALLOW_UPGRADE
+ | MHD_USE_ERROR_LOG,
PORT, NULL, NULL,
&access_handler, NULL,
MHD_OPTION_END);
@@ -550,9 +558,9 @@ main (int argc,
fprintf (stderr, "Error (Couldn't start daemon for testing)\n");
return 1;
}
- printf("The server is listening now.\n");
- printf("Access the server now with a websocket-capable webbrowser.\n\n");
- printf("Press return to close.\n");
+ printf ("The server is listening now.\n");
+ printf ("Access the server now with a websocket-capable webbrowser.\n\n");
+ printf ("Press return to close.\n");
(void) getc (stdin);
@@ -560,4 +568,3 @@ main (int argc,
return 0;
}
-
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.