-fix tests for libmagic (and uncrustify indentation)

This commit is contained in:
Christian Grothoff
2021-12-08 14:11:31 +01:00
parent 43938f8d41
commit dbe1d76d9c
33 changed files with 531 additions and 530 deletions
+3 -3
View File
@@ -1996,7 +1996,7 @@ AC_LINK_IFELSE(
)
],
[
AC_DEFINE([HAVE_LIBMAGIC], [1], [Define to 1 if you have suitable libmagic.])
AC_DEFINE([MHD_HAVE_LIBMAGIC], [1], [Define to 1 if you have suitable libmagic.])
mhd_have_libmagic="yes"
AC_MSG_RESULT([[yes]])
],
@@ -2004,7 +2004,7 @@ AC_LINK_IFELSE(
]
)
LIBS="$SAVE_LIBS"
AM_CONDITIONAL([HAVE_LIBMAGIC], [[test "x$mhd_have_libmagic" = "xyes"]])
AM_CONDITIONAL([MHD_HAVE_LIBMAGIC], [[test "x$mhd_have_libmagic" = "xyes"]])
# large file support (> 4 GB)
AC_SYS_LARGEFILE
@@ -2800,7 +2800,7 @@ AM_CONDITIONAL([USE_COVERAGE], [test "x$use_gcov" = "xyes"])
AX_COUNT_CPUS
AC_MSG_CHECKING([for number of CPU cores to use in tests])
AS_VAR_IF([enable_heavy_tests], ["yes"],
[
[
# Enable usage of many core if heavy tests are enabled
AS_IF([[test "$CPU_COUNT" -gt "32"]], [[CPU_COUNT="32"]])dnl Limit resource usage
],
+2 -2
View File
@@ -143,7 +143,7 @@ demo_CPPFLAGS = \
demo_LDADD = \
$(top_builddir)/src/microhttpd/libmicrohttpd.la \
$(PTHREAD_LIBS)
if HAVE_LIBMAGIC
if MHD_HAVE_LIBMAGIC
demo_LDADD += -lmagic
endif
@@ -156,7 +156,7 @@ demo_https_CPPFLAGS = \
demo_https_LDADD = \
$(top_builddir)/src/microhttpd/libmicrohttpd.la \
$(PTHREAD_LIBS)
if HAVE_LIBMAGIC
if MHD_HAVE_LIBMAGIC
demo_https_LDADD += -lmagic
endif
+2 -1
View File
@@ -28,6 +28,7 @@
* to be adjusted depending on the number of available cores.
* @author Christian Grothoff
*/
#include "MHD_config.h"
#include "platform.h"
#include <microhttpd.h>
#include <unistd.h>
@@ -568,7 +569,7 @@ process_upload_data (void *cls,
uc->language,
uc->category,
filename);
for (i = strlen (fn) - 1; i>=0; i--)
for (i = strlen (fn) - 1; i >= 0; i--)
if (! isprint ((unsigned char) fn[i]))
fn[i] = '_';
uc->fd = open (fn,
+1 -1
View File
@@ -571,7 +571,7 @@ process_upload_data (void *cls,
uc->language,
uc->category,
filename);
for (i = strlen (fn) - 1; i>=0; i--)
for (i = strlen (fn) - 1; i >= 0; i--)
if (! isprint ((unsigned char) fn[i]))
fn[i] = '_';
uc->fd = open (fn,
+2 -2
View File
@@ -25,7 +25,7 @@ struct StdCallThread
DWORD WINAPI
ThreadProc (LPVOID lpParameter)
{
struct StdCallThread st = *((struct StdCallThread*) lpParameter);
struct StdCallThread st = *((struct StdCallThread *) lpParameter);
free (lpParameter);
st.start (st.arg);
return 0;
@@ -42,7 +42,7 @@ pthread_create (pthread_t *pt,
if (NULL == pt_)
return 1;
struct StdCallThread *sct;
sct = (struct StdCallThread*) malloc (sizeof(struct StdCallThread));
sct = (struct StdCallThread *) malloc (sizeof(struct StdCallThread));
if (NULL == sct)
{
free (pt_);
+1 -1
View File
@@ -53,7 +53,7 @@ ahc_echo (void *cls,
{
struct MHD_Response *response;
enum MHD_Result ret;
struct Request*req;
struct Request *req;
struct itimerspec ts;
(void) cls;
+423 -423
View File
@@ -186,429 +186,429 @@
" function window_onload(event)\n" \
" {\n" \
" // Determine the base url (for http:// this is ws:// for https:// this must be wss://)\n" \
" baseUrl = 'ws' + (window.location.protocol === 'https:' ? 's' : '') + '://' + window.location.host + '/ChatServerWebSocket';\n" \
" chat_generate();\n" \
" chat_connect();\n" \
" }\n" \
"\n" \
" /**\n" \
" This function generates the chat using DOM\n" \
" */\n" \
" function chat_generate()\n" \
" {\n" \
" document.body.innerHTML = '';\n" \
" let chat = document.createElement('div');\n" \
" document.body.appendChild(chat);\n" \
" chat.id = 'Chat';\n" \
" let messagesAndInput = document.createElement('div');\n" \
" chat.appendChild(messagesAndInput);\n" \
" messagesAndInput.classList.add('MessagesAndInput');\n" \
" let messages = document.createElement('div');\n" \
" messagesAndInput.appendChild(messages);\n" \
" messages.id = 'Messages';\n" \
" let input = document.createElement('div');\n" \
" messagesAndInput.appendChild(input);\n" \
" input.classList.add('Input');\n" \
" let inputMessage = document.createElement('input');\n" \
" input.appendChild(inputMessage);\n" \
" inputMessage.type = 'text';\n" \
" inputMessage.id = 'InputMessage';\n" \
" inputMessage.disabled = true;\n" \
" inputMessage.addEventListener('keydown', chat_onKeyDown);\n" \
" let inputMessageSend = document.createElement('button');\n" \
" input.appendChild(inputMessageSend);\n" \
" inputMessageSend.id = 'InputMessageButton';\n" \
" inputMessageSend.disabled = true;\n" \
" inputMessageSend.innerText = 'send';\n" \
" inputMessageSend.addEventListener('click', chat_onSendClicked);\n" \
" let inputImage = document.createElement('input');\n" \
" input.appendChild(inputImage);\n" \
" inputImage.id = 'InputImage';\n" \
" inputImage.type = 'file';\n" \
" inputImage.accept = 'image/*';\n" \
" inputImage.style.display = 'none';\n" \
" inputImage.addEventListener('change', chat_onImageSelected);\n" \
" let inputImageButton = document.createElement('button');\n" \
" input.appendChild(inputImageButton);\n" \
" inputImageButton.id = 'InputImageButton';\n" \
" inputImageButton.disabled = true;\n" \
" inputImageButton.innerText = 'image';\n" \
" inputImageButton.addEventListener('click', chat_onImageClicked);\n" \
" let users = document.createElement('div');\n" \
" chat.appendChild(users);\n" \
" users.id = 'Users';\n" \
" users.addEventListener('click', chat_onUserClicked);\n" \
" let allUsers = document.createElement('div');\n" \
" users.appendChild(allUsers);\n" \
" allUsers.classList.add('selected');\n" \
" allUsers.innerText = '<everyone>';\n" \
" allUsers.setAttribute('data-user', '0');\n" \
" }\n" \
"\n" \
" /**\n" \
" This function creates and connects a WebSocket\n" \
" */\n" \
" function chat_connect()\n" \
" {\n" \
" chat_addMessage(`Connecting to libmicrohttpd chat server demo (${baseUrl})...`, { type: 'system' });\n" \
" socket = new WebSocket(baseUrl);\n" \
" socket.binaryType = 'arraybuffer';\n" \
" socket.onopen = socket_onopen;\n" \
" socket.onclose = socket_onclose;\n" \
" socket.onerror = socket_onerror;\n" \
" socket.onmessage = socket_onmessage;\n" \
" }\n" \
"\n" \
" /**\n" \
" This function adds new text to the chat list\n" \
" */\n" \
" function chat_addMessage(text, options)\n" \
" {\n" \
" let type = options && options.type || 'regular';\n" \
" if(!/^(?:regular|system|error|private|moderator)$/.test(type))\n" \
" type = 'regular';\n" \
" let message = document.createElement('div');\n" \
" message.classList.add('Message');\n" \
" message.classList.add(type);\n" \
" if(typeof(text) === 'string')\n" \
" {\n" \
" let content = document.createElement('span');\n" \
" message.appendChild(content);\n" \
" if(options && options.from)\n" \
" content.innerText = `${options.from}: ${text}`;\n" \
" else\n" \
" content.innerText = text;\n" \
" if(options && options.reconnect)\n" \
" {\n" \
" let span = document.createElement('span');\n" \
" span.appendChild(document.createTextNode(' ('));\n" \
" let reconnect = document.createElement('a');\n" \
" reconnect.href = 'javascript:chat_connect()';\n" \
" reconnect.innerText = 'reconnect';\n" \
" span.appendChild(reconnect);\n" \
" span.appendChild(document.createTextNode(')'));\n" \
" message.appendChild(span);\n" \
" }\n" \
" }\n" \
" else\n" \
" {\n" \
" let content = document.createElement('span');\n" \
" message.appendChild(content);\n" \
" if(options && options.from)\n" \
" {\n" \
" content.innerText = `${options.from}:\\n`;\n" \
" }\n" \
" if(options && options.pictureType && text instanceof Uint8Array)\n" \
" {\n" \
" let img = document.createElement('img');\n" \
" content.appendChild(img);\n" \
" img.src = URL.createObjectURL(new Blob([ text.buffer ], { type: options.pictureType }));\n" \
" }\n" \
" }\n" \
" document.getElementById('Messages').appendChild(message);\n" \
" message.scrollIntoView();\n" \
" }\n" \
"\n" \
" /**\n" \
" This is a keydown event handler, which allows that you can just press enter instead of clicking the 'send' button\n" \
" */\n" \
" function chat_onKeyDown(event)\n" \
" {\n" \
" if(event.key == 'Enter')\n" \
" chat_onSendClicked();\n" \
" }\n" \
"\n" \
" /**\n" \
" This is the code to send a message or command, when clicking the 'send' button\n" \
" */\n" \
" function chat_onSendClicked(event)\n" \
" {\n" \
" let message = document.getElementById('InputMessage').value;\n" \
" if(message.length == 0)\n" \
" return;\n" \
" if(message.substr(0, 1) == '/')\n" \
" {\n" \
" // command\n" \
" let match;\n" \
" if(/^\\/disconnect\\s*$/.test(message))\n" \
" {\n" \
" socket.close(1000);\n" \
" }\n" \
" else if((match = /^\\/m\\s+(\\S+)\\s+/.exec(message)))\n" \
" {\n" \
" message = message.substr(match[0].length);\n" \
" let userId = chat_getUserIdByName(match[1]);\n" \
" if(userId !== null)\n" \
" {\n" \
" socket.send(`private|${userId}|${message}`);\n" \
" }\n" \
" else\n" \
" {\n" \
" chat_addMessage(`Unknown user \"${match[1]}\" for private message: ${message}`, { type: 'error' });\n" \
" }\n" \
" }\n" \
" else if((match = /^\\/ping\\s+(\\S+)\\s*$/.exec(message)))\n" \
" {\n" \
" let userId = chat_getUserIdByName(match[1]);\n" \
" if(userId !== null)\n" \
" {\n" \
" socket.send(`ping|${userId}|`);\n" \
" }\n" \
" else\n" \
" {\n" \
" chat_addMessage(`Unknown user \"${match[1]}\" for ping`, { type: 'error' });\n" \
" }\n" \
" }\n" \
" else if((match = /^\\/name\\s+(\\S+)\\s*$/.exec(message)))\n" \
" {\n" \
" socket.send(`name||${match[1]}`);\n" \
" }\n" \
" else\n" \
" {\n" \
" chat_addMessage(`Unsupported command or invalid syntax: ${message}`, { type: 'error' });\n" \
" }\n" \
" }\n" \
" else\n" \
" {\n" \
" // regular chat message to the selected user\n" \
" let selectedUser = document.querySelector('div#Users > div.selected');\n" \
" let selectedUserId = parseInt(selectedUser.getAttribute('data-user') || '0', 10);\n" \
" if(selectedUserId == 0)\n" \
" socket.send(`||${message}`);\n" \
" else\n" \
" socket.send(`private|${selectedUserId}|${message}`);\n" \
" }\n" \
" document.getElementById('InputMessage').value = '';\n" \
" }\n" \
"\n" \
" /**\n" \
" This is the event when the user hits the 'image' button\n" \
" */\n" \
" function chat_onImageClicked(event)\n" \
" {\n" \
" document.getElementById('InputImage').click();\n" \
" }\n" \
"\n" \
" /**\n" \
" This is the event when the user selected an image.\n" \
" The image will be read with the FileReader (allowed in web, because the user selected the file).\n" \
" */\n" \
" function chat_onImageSelected(event)\n" \
" {\n" \
" let file = event.target.files[0];\n" \
" if(!file || !/^image\\//.test(file.type))\n" \
" return;\n" \
" let selectedUser = document.querySelector('div#Users > div.selected');\n" \
" let selectedUserId = parseInt(selectedUser.getAttribute('data-user') || '0', 10);\n" \
" let reader = new FileReader();\n" \
" reader.onload = function(event) {\n" \
" chat_onImageRead(event, file.type, selectedUserId);\n" \
" };\n" \
" reader.readAsArrayBuffer(file);\n" \
" }\n" \
"\n" \
" /**\n" \
" This is the event when the user selected image has been read.\n" \
" This will add our chat protocol prefix and send it via the websocket.\n" \
" */\n" \
" function chat_onImageRead(event, fileType, selectedUserId)\n" \
" {\n" \
" let encoder = new TextEncoder();\n" \
" let prefix = ((selectedUserId == 0 ? '||' : `private|${selectedUserId}|`) + fileType + '|');\n" \
" prefix = encoder.encode(prefix);\n" \
" let byteData = new Uint8Array(event.target.result);\n" \
" let totalLength = prefix.length + byteData.length;\n" \
" let resultByteData = new Uint8Array(totalLength);\n" \
" resultByteData.set(prefix, 0);\n" \
" resultByteData.set(byteData, prefix.length);\n" \
" socket.send(resultByteData);\n" \
" }\n" \
"\n" \
" /**\n" \
" This is the event when the user clicked a name in the user list.\n" \
" This is useful to send private messages or images without needing to add the /m prefix.\n" \
" */\n" \
" function chat_onUserClicked(event, selectedUserId)\n" \
" {\n" \
" let newSelected = event.target.closest('div#Users > div');\n" \
" if(newSelected === null)\n" \
" return;\n" \
" for(let div of this.querySelectorAll(':scope > div.selected'))\n" \
" div.classList.remove('selected');\n" \
" newSelected.classList.add('selected');\n" \
" }\n" \
"\n" \
" /**\n" \
" This functions returns the current id of a user identified by its name.\n" \
" */\n" \
" function chat_getUserIdByName(name)\n" \
" {\n" \
" let nameUpper = name.toUpperCase();\n" \
" for(let pair of connectedUsers)\n" \
" {\n" \
" if(pair[1].toUpperCase() == nameUpper)\n" \
" return pair[0];\n" \
" }\n" \
" return null;\n" \
" }\n" \
"\n" \
" /**\n" \
" This functions clears the entire user list (needed for reconnecting).\n" \
" */\n" \
" function chat_clearUserList()\n" \
" {\n" \
" let users = document.getElementById('Users');\n" \
" for(let div of users.querySelectorAll(':scope > div'))\n" \
" {\n" \
" if(div.getAttribute('data-user') === '0')\n" \
" {\n" \
" div.classList.add('selected');\n" \
" }\n" \
" else\n" \
" {\n" \
" div.parentNode.removeChild(div);\n" \
" }\n" \
" }\n" \
" return null;\n" \
" }\n" \
"\n" \
" /**\n" \
" This is the event when the socket has established a connection.\n" \
" This will initialize an empty chat and enable the controls.\n" \
" */\n" \
" function socket_onopen(event)\n" \
" {\n" \
" connectedUsers.clear();\n" \
" chat_clearUserList();\n" \
" chat_addMessage('Connected!', { type: 'system' });\n" \
" document.getElementById('InputMessage').disabled = false;\n" \
" document.getElementById('InputMessageButton').disabled = false;\n" \
" document.getElementById('InputImageButton').disabled = false;\n" \
" }\n" \
"\n" \
" /**\n" \
" This is the event when the socket has been closed.\n" \
" This will lock the controls.\n" \
" */\n" \
" function socket_onclose(event)\n" \
" {\n" \
" chat_addMessage('Connection closed!', { type: 'system', reconnect: true });\n" \
" document.getElementById('InputMessage').disabled = true;\n" \
" document.getElementById('InputMessageButton').disabled = true;\n" \
" document.getElementById('InputImageButton').disabled = true;\n" \
" }\n" \
"\n" \
" /**\n" \
" This is the event when the socket reported an error.\n" \
" This will just make an output.\n" \
" In the web browser console (F12 on many browsers) will show you more detailed error information.\n" \
" */\n" \
" function socket_onerror(event)\n" \
" {\n" \
" console.error('WebSocket error reported: ', event);\n" \
" chat_addMessage('The socket reported an error!', { type: 'error' });\n" \
" }\n" \
"\n" \
" /**\n" \
" This is the event when the socket has received a message.\n" \
" This will parse the message and execute the corresponding command (or add the message).\n" \
" */\n" \
" function socket_onmessage(event)\n" \
" {\n" \
" if(typeof(event.data) === 'string')\n" \
" {\n" \
" // text message or command\n" \
" let message = event.data.split('|', 3);\n" \
" switch(message[0])\n" \
" {\n" \
" case 'userinit':\n" \
" connectedUsers.set(message[1], message[2]);\n" \
" {\n" \
" let users = document.getElementById('Users');\n" \
" let div = document.createElement('div');\n" \
" users.appendChild(div);\n" \
" div.innerText = message[2];\n" \
" div.setAttribute('data-user', message[1]);\n" \
" }\n" \
" break;\n" \
" case 'useradd':\n" \
" connectedUsers.set(message[1], message[2]);\n" \
" chat_addMessage(`The user '${message[2]}' has joined our lovely chatroom.`, { type: 'moderator' });\n" \
" {\n" \
" let users = document.getElementById('Users');\n" \
" let div = document.createElement('div');\n" \
" users.appendChild(div);\n" \
" div.innerText = message[2];\n" \
" div.setAttribute('data-user', message[1]);\n" \
" }\n" \
" break;\n" \
" case 'userdel':\n" \
" chat_addMessage(`The user '${connectedUsers.get(message[1])}' has left our chatroom. We will miss you.`, { type: 'moderator' });\n" \
" connectedUsers.delete(message[1]);\n" \
" {\n" \
" let users = document.getElementById('Users');\n" \
" let div = users.querySelector(`div[data-user='${message[1]}']`);\n" \
" if(div !== null)\n" \
" {\n" \
" users.removeChild(div);\n" \
" if(div.classList.contains('selected'))\n" \
" users.querySelector('div[data-user=\\'0\\']').classList.add('selected');\n" \
" }\n" \
" }\n" \
" break;\n" \
" case 'username':\n" \
" chat_addMessage(`The user '${connectedUsers.get(message[1])}' has changed his name to '${message[2]}'.`, { type: 'moderator' });\n" \
" connectedUsers.set(message[1], message[2]);\n" \
" {\n" \
" let users = document.getElementById('Users');\n" \
" let div = users.querySelector(`div[data-user='${message[1]}']`);\n" \
" if(div !== null)\n" \
" {\n" \
" div.innerText = message[2];\n" \
" }\n" \
" }\n" \
" break;\n" \
" case 'ping':\n" \
" chat_addMessage(`The user '${connectedUsers.get(message[1])}' has a ping of ${message[2]} ms.`, { type: 'moderator' });\n" \
" break;\n" \
" default:\n" \
" chat_addMessage(message[2], { type: message[0], from: connectedUsers.get(message[1]) });\n" \
" break;\n" \
" }\n" \
" }\n" \
" else\n" \
" {\n" \
" // We received a binary frame, which means a picture here\n" \
" let byteData = new Uint8Array(event.data);\n" \
" let decoder = new TextDecoder();\n" \
" let message = [ ];\n" \
" // message type\n" \
" let j = 0;\n" \
" let i = byteData.indexOf(0x7C, j); // | = 0x7C;\n" \
" if(i < 0)\n" \
" return;\n" \
" message.push(decoder.decode(byteData.slice(0, i)));\n" \
" // picture from\n" \
" j = i + 1;\n" \
" i = byteData.indexOf(0x7C, j);\n" \
" if(i < 0)\n" \
" return;\n" \
" message.push(decoder.decode(byteData.slice(j, i)));\n" \
" // picture encoding\n" \
" j = i + 1;\n" \
" i = byteData.indexOf(0x7C, j);\n" \
" if(i < 0)\n" \
" return;\n" \
" message.push(decoder.decode(byteData.slice(j, i)));\n" \
" // picture\n" \
" byteData = byteData.slice(i + 1);\n" \
" chat_addMessage(byteData, { type: message[0], from: connectedUsers.get(message[1]), pictureType: message[2] });\n" \
" }\n" \
" }\n" \
"</script>" \
"</head>" \
"<body><noscript>Please enable JavaScript to test the libmicrohttpd Websocket chatserver demo!</noscript></body>" \
"</html>"
// " baseUrl = 'ws' + (window.location.protocol === 'https:' ? 's' : '') + '://' + window.location.host + '/ChatServerWebSocket';\n" \
// " chat_generate();\n" \
// " chat_connect();\n" \
// " }\n" \
// "\n" \
// " /**\n" \
// " This function generates the chat using DOM\n" \
// " */\n" \
// " function chat_generate()\n" \
// " {\n" \
// " document.body.innerHTML = '';\n" \
// " let chat = document.createElement('div');\n" \
// " document.body.appendChild(chat);\n" \
// " chat.id = 'Chat';\n" \
// " let messagesAndInput = document.createElement('div');\n" \
// " chat.appendChild(messagesAndInput);\n" \
// " messagesAndInput.classList.add('MessagesAndInput');\n" \
// " let messages = document.createElement('div');\n" \
// " messagesAndInput.appendChild(messages);\n" \
// " messages.id = 'Messages';\n" \
// " let input = document.createElement('div');\n" \
// " messagesAndInput.appendChild(input);\n" \
// " input.classList.add('Input');\n" \
// " let inputMessage = document.createElement('input');\n" \
// " input.appendChild(inputMessage);\n" \
// " inputMessage.type = 'text';\n" \
// " inputMessage.id = 'InputMessage';\n" \
// " inputMessage.disabled = true;\n" \
// " inputMessage.addEventListener('keydown', chat_onKeyDown);\n" \
// " let inputMessageSend = document.createElement('button');\n" \
// " input.appendChild(inputMessageSend);\n" \
// " inputMessageSend.id = 'InputMessageButton';\n" \
// " inputMessageSend.disabled = true;\n" \
// " inputMessageSend.innerText = 'send';\n" \
// " inputMessageSend.addEventListener('click', chat_onSendClicked);\n" \
// " let inputImage = document.createElement('input');\n" \
// " input.appendChild(inputImage);\n" \
// " inputImage.id = 'InputImage';\n" \
// " inputImage.type = 'file';\n" \
// " inputImage.accept = 'image/*';\n" \
// " inputImage.style.display = 'none';\n" \
// " inputImage.addEventListener('change', chat_onImageSelected);\n" \
// " let inputImageButton = document.createElement('button');\n" \
// " input.appendChild(inputImageButton);\n" \
// " inputImageButton.id = 'InputImageButton';\n" \
// " inputImageButton.disabled = true;\n" \
// " inputImageButton.innerText = 'image';\n" \
// " inputImageButton.addEventListener('click', chat_onImageClicked);\n" \
// " let users = document.createElement('div');\n" \
// " chat.appendChild(users);\n" \
// " users.id = 'Users';\n" \
// " users.addEventListener('click', chat_onUserClicked);\n" \
// " let allUsers = document.createElement('div');\n" \
// " users.appendChild(allUsers);\n" \
// " allUsers.classList.add('selected');\n" \
// " allUsers.innerText = '<everyone>';\n" \
// " allUsers.setAttribute('data-user', '0');\n" \
// " }\n" \
// "\n" \
// " /**\n" \
// " This function creates and connects a WebSocket\n" \
// " */\n" \
// " function chat_connect()\n" \
// " {\n" \
// " chat_addMessage(`Connecting to libmicrohttpd chat server demo (${baseUrl})...`, { type: 'system' });\n" \
// " socket = new WebSocket(baseUrl);\n" \
// " socket.binaryType = 'arraybuffer';\n" \
// " socket.onopen = socket_onopen;\n" \
// " socket.onclose = socket_onclose;\n" \
// " socket.onerror = socket_onerror;\n" \
// " socket.onmessage = socket_onmessage;\n" \
// " }\n" \
// "\n" \
// " /**\n" \
// " This function adds new text to the chat list\n" \
// " */\n" \
// " function chat_addMessage(text, options)\n" \
// " {\n" \
// " let type = options && options.type || 'regular';\n" \
// " if(!/^(?:regular|system|error|private|moderator)$/.test(type))\n" \
// " type = 'regular';\n" \
// " let message = document.createElement('div');\n" \
// " message.classList.add('Message');\n" \
// " message.classList.add(type);\n" \
// " if(typeof(text) === 'string')\n" \
// " {\n" \
// " let content = document.createElement('span');\n" \
// " message.appendChild(content);\n" \
// " if(options && options.from)\n" \
// " content.innerText = `${options.from}: ${text}`;\n" \
// " else\n" \
// " content.innerText = text;\n" \
// " if(options && options.reconnect)\n" \
// " {\n" \
// " let span = document.createElement('span');\n" \
// " span.appendChild(document.createTextNode(' ('));\n" \
// " let reconnect = document.createElement('a');\n" \
// " reconnect.href = 'javascript:chat_connect()';\n" \
// " reconnect.innerText = 'reconnect';\n" \
// " span.appendChild(reconnect);\n" \
// " span.appendChild(document.createTextNode(')'));\n" \
// " message.appendChild(span);\n" \
// " }\n" \
// " }\n" \
// " else\n" \
// " {\n" \
// " let content = document.createElement('span');\n" \
// " message.appendChild(content);\n" \
// " if(options && options.from)\n" \
// " {\n" \
// " content.innerText = `${options.from}:\\n`;\n" \
// " }\n" \
// " if(options && options.pictureType && text instanceof Uint8Array)\n" \
// " {\n" \
// " let img = document.createElement('img');\n" \
// " content.appendChild(img);\n" \
// " img.src = URL.createObjectURL(new Blob([ text.buffer ], { type: options.pictureType }));\n" \
// " }\n" \
// " }\n" \
// " document.getElementById('Messages').appendChild(message);\n" \
// " message.scrollIntoView();\n" \
// " }\n" \
// "\n" \
// " /**\n" \
// " This is a keydown event handler, which allows that you can just press enter instead of clicking the 'send' button\n" \
// " */\n" \
// " function chat_onKeyDown(event)\n" \
// " {\n" \
// " if(event.key == 'Enter')\n" \
// " chat_onSendClicked();\n" \
// " }\n" \
// "\n" \
// " /**\n" \
// " This is the code to send a message or command, when clicking the 'send' button\n" \
// " */\n" \
// " function chat_onSendClicked(event)\n" \
// " {\n" \
// " let message = document.getElementById('InputMessage').value;\n" \
// " if(message.length == 0)\n" \
// " return;\n" \
// " if(message.substr(0, 1) == '/')\n" \
// " {\n" \
// " // command\n" \
// " let match;\n" \
// " if(/^\\/disconnect\\s*$/.test(message))\n" \
// " {\n" \
// " socket.close(1000);\n" \
// " }\n" \
// " else if((match = /^\\/m\\s+(\\S+)\\s+/.exec(message)))\n" \
// " {\n" \
// " message = message.substr(match[0].length);\n" \
// " let userId = chat_getUserIdByName(match[1]);\n" \
// " if(userId !== null)\n" \
// " {\n" \
// " socket.send(`private|${userId}|${message}`);\n" \
// " }\n" \
// " else\n" \
// " {\n" \
// " chat_addMessage(`Unknown user \"${match[1]}\" for private message: ${message}`, { type: 'error' });\n" \
// " }\n" \
// " }\n" \
// " else if((match = /^\\/ping\\s+(\\S+)\\s*$/.exec(message)))\n" \
// " {\n" \
// " let userId = chat_getUserIdByName(match[1]);\n" \
// " if(userId !== null)\n" \
// " {\n" \
// " socket.send(`ping|${userId}|`);\n" \
// " }\n" \
// " else\n" \
// " {\n" \
// " chat_addMessage(`Unknown user \"${match[1]}\" for ping`, { type: 'error' });\n" \
// " }\n" \
// " }\n" \
// " else if((match = /^\\/name\\s+(\\S+)\\s*$/.exec(message)))\n" \
// " {\n" \
// " socket.send(`name||${match[1]}`);\n" \
// " }\n" \
// " else\n" \
// " {\n" \
// " chat_addMessage(`Unsupported command or invalid syntax: ${message}`, { type: 'error' });\n" \
// " }\n" \
// " }\n" \
// " else\n" \
// " {\n" \
// " // regular chat message to the selected user\n" \
// " let selectedUser = document.querySelector('div#Users > div.selected');\n" \
// " let selectedUserId = parseInt(selectedUser.getAttribute('data-user') || '0', 10);\n" \
// " if(selectedUserId == 0)\n" \
// " socket.send(`||${message}`);\n" \
// " else\n" \
// " socket.send(`private|${selectedUserId}|${message}`);\n" \
// " }\n" \
// " document.getElementById('InputMessage').value = '';\n" \
// " }\n" \
// "\n" \
// " /**\n" \
// " This is the event when the user hits the 'image' button\n" \
// " */\n" \
// " function chat_onImageClicked(event)\n" \
// " {\n" \
// " document.getElementById('InputImage').click();\n" \
// " }\n" \
// "\n" \
// " /**\n" \
// " This is the event when the user selected an image.\n" \
// " The image will be read with the FileReader (allowed in web, because the user selected the file).\n" \
// " */\n" \
// " function chat_onImageSelected(event)\n" \
// " {\n" \
// " let file = event.target.files[0];\n" \
// " if(!file || !/^image\\//.test(file.type))\n" \
// " return;\n" \
// " let selectedUser = document.querySelector('div#Users > div.selected');\n" \
// " let selectedUserId = parseInt(selectedUser.getAttribute('data-user') || '0', 10);\n" \
// " let reader = new FileReader();\n" \
// " reader.onload = function(event) {\n" \
// " chat_onImageRead(event, file.type, selectedUserId);\n" \
// " };\n" \
// " reader.readAsArrayBuffer(file);\n" \
// " }\n" \
// "\n" \
// " /**\n" \
// " This is the event when the user selected image has been read.\n" \
// " This will add our chat protocol prefix and send it via the websocket.\n" \
// " */\n" \
// " function chat_onImageRead(event, fileType, selectedUserId)\n" \
// " {\n" \
// " let encoder = new TextEncoder();\n" \
// " let prefix = ((selectedUserId == 0 ? '||' : `private|${selectedUserId}|`) + fileType + '|');\n" \
// " prefix = encoder.encode(prefix);\n" \
// " let byteData = new Uint8Array(event.target.result);\n" \
// " let totalLength = prefix.length + byteData.length;\n" \
// " let resultByteData = new Uint8Array(totalLength);\n" \
// " resultByteData.set(prefix, 0);\n" \
// " resultByteData.set(byteData, prefix.length);\n" \
// " socket.send(resultByteData);\n" \
// " }\n" \
// "\n" \
// " /**\n" \
// " This is the event when the user clicked a name in the user list.\n" \
// " This is useful to send private messages or images without needing to add the /m prefix.\n" \
// " */\n" \
// " function chat_onUserClicked(event, selectedUserId)\n" \
// " {\n" \
// " let newSelected = event.target.closest('div#Users > div');\n" \
// " if(newSelected === null)\n" \
// " return;\n" \
// " for(let div of this.querySelectorAll(':scope > div.selected'))\n" \
// " div.classList.remove('selected');\n" \
// " newSelected.classList.add('selected');\n" \
// " }\n" \
// "\n" \
// " /**\n" \
// " This functions returns the current id of a user identified by its name.\n" \
// " */\n" \
// " function chat_getUserIdByName(name)\n" \
// " {\n" \
// " let nameUpper = name.toUpperCase();\n" \
// " for(let pair of connectedUsers)\n" \
// " {\n" \
// " if(pair[1].toUpperCase() == nameUpper)\n" \
// " return pair[0];\n" \
// " }\n" \
// " return null;\n" \
// " }\n" \
// "\n" \
// " /**\n" \
// " This functions clears the entire user list (needed for reconnecting).\n" \
// " */\n" \
// " function chat_clearUserList()\n" \
// " {\n" \
// " let users = document.getElementById('Users');\n" \
// " for(let div of users.querySelectorAll(':scope > div'))\n" \
// " {\n" \
// " if(div.getAttribute('data-user') === '0')\n" \
// " {\n" \
// " div.classList.add('selected');\n" \
// " }\n" \
// " else\n" \
// " {\n" \
// " div.parentNode.removeChild(div);\n" \
// " }\n" \
// " }\n" \
// " return null;\n" \
// " }\n" \
// "\n" \
// " /**\n" \
// " This is the event when the socket has established a connection.\n" \
// " This will initialize an empty chat and enable the controls.\n" \
// " */\n" \
// " function socket_onopen(event)\n" \
// " {\n" \
// " connectedUsers.clear();\n" \
// " chat_clearUserList();\n" \
// " chat_addMessage('Connected!', { type: 'system' });\n" \
// " document.getElementById('InputMessage').disabled = false;\n" \
// " document.getElementById('InputMessageButton').disabled = false;\n" \
// " document.getElementById('InputImageButton').disabled = false;\n" \
// " }\n" \
// "\n" \
// " /**\n" \
// " This is the event when the socket has been closed.\n" \
// " This will lock the controls.\n" \
// " */\n" \
// " function socket_onclose(event)\n" \
// " {\n" \
// " chat_addMessage('Connection closed!', { type: 'system', reconnect: true });\n" \
// " document.getElementById('InputMessage').disabled = true;\n" \
// " document.getElementById('InputMessageButton').disabled = true;\n" \
// " document.getElementById('InputImageButton').disabled = true;\n" \
// " }\n" \
// "\n" \
// " /**\n" \
// " This is the event when the socket reported an error.\n" \
// " This will just make an output.\n" \
// " In the web browser console (F12 on many browsers) will show you more detailed error information.\n" \
// " */\n" \
// " function socket_onerror(event)\n" \
// " {\n" \
// " console.error('WebSocket error reported: ', event);\n" \
// " chat_addMessage('The socket reported an error!', { type: 'error' });\n" \
// " }\n" \
// "\n" \
// " /**\n" \
// " This is the event when the socket has received a message.\n" \
// " This will parse the message and execute the corresponding command (or add the message).\n" \
// " */\n" \
// " function socket_onmessage(event)\n" \
// " {\n" \
// " if(typeof(event.data) === 'string')\n" \
// " {\n" \
// " // text message or command\n" \
// " let message = event.data.split('|', 3);\n" \
// " switch(message[0])\n" \
// " {\n" \
// " case 'userinit':\n" \
// " connectedUsers.set(message[1], message[2]);\n" \
// " {\n" \
// " let users = document.getElementById('Users');\n" \
// " let div = document.createElement('div');\n" \
// " users.appendChild(div);\n" \
// " div.innerText = message[2];\n" \
// " div.setAttribute('data-user', message[1]);\n" \
// " }\n" \
// " break;\n" \
// " case 'useradd':\n" \
// " connectedUsers.set(message[1], message[2]);\n" \
// " chat_addMessage(`The user '${message[2]}' has joined our lovely chatroom.`, { type: 'moderator' });\n" \
// " {\n" \
// " let users = document.getElementById('Users');\n" \
// " let div = document.createElement('div');\n" \
// " users.appendChild(div);\n" \
// " div.innerText = message[2];\n" \
// " div.setAttribute('data-user', message[1]);\n" \
// " }\n" \
// " break;\n" \
// " case 'userdel':\n" \
// " chat_addMessage(`The user '${connectedUsers.get(message[1])}' has left our chatroom. We will miss you.`, { type: 'moderator' });\n" \
// " connectedUsers.delete(message[1]);\n" \
// " {\n" \
// " let users = document.getElementById('Users');\n" \
// " let div = users.querySelector(`div[data-user='${message[1]}']`);\n" \
// " if(div !== null)\n" \
// " {\n" \
// " users.removeChild(div);\n" \
// " if(div.classList.contains('selected'))\n" \
// " users.querySelector('div[data-user=\\'0\\']').classList.add('selected');\n" \
// " }\n" \
// " }\n" \
// " break;\n" \
// " case 'username':\n" \
// " chat_addMessage(`The user '${connectedUsers.get(message[1])}' has changed his name to '${message[2]}'.`, { type: 'moderator' });\n" \
// " connectedUsers.set(message[1], message[2]);\n" \
// " {\n" \
// " let users = document.getElementById('Users');\n" \
// " let div = users.querySelector(`div[data-user='${message[1]}']`);\n" \
// " if(div !== null)\n" \
// " {\n" \
// " div.innerText = message[2];\n" \
// " }\n" \
// " }\n" \
// " break;\n" \
// " case 'ping':\n" \
// " chat_addMessage(`The user '${connectedUsers.get(message[1])}' has a ping of ${message[2]} ms.`, { type: 'moderator' });\n" \
// " break;\n" \
// " default:\n" \
// " chat_addMessage(message[2], { type: message[0], from: connectedUsers.get(message[1]) });\n" \
// " break;\n" \
// " }\n" \
// " }\n" \
// " else\n" \
// " {\n" \
// " // We received a binary frame, which means a picture here\n" \
// " let byteData = new Uint8Array(event.data);\n" \
// " let decoder = new TextDecoder();\n" \
// " let message = [ ];\n" \
// " // message type\n" \
// " let j = 0;\n" \
// " let i = byteData.indexOf(0x7C, j); // | = 0x7C;\n" \
// " if(i < 0)\n" \
// " return;\n" \
// " message.push(decoder.decode(byteData.slice(0, i)));\n" \
// " // picture from\n" \
// " j = i + 1;\n" \
// " i = byteData.indexOf(0x7C, j);\n" \
// " if(i < 0)\n" \
// " return;\n" \
// " message.push(decoder.decode(byteData.slice(j, i)));\n" \
// " // picture encoding\n" \
// " j = i + 1;\n" \
// " i = byteData.indexOf(0x7C, j);\n" \
// " if(i < 0)\n" \
// " return;\n" \
// " message.push(decoder.decode(byteData.slice(j, i)));\n" \
// " // picture\n" \
// " byteData = byteData.slice(i + 1);\n" \
// " chat_addMessage(byteData, { type: message[0], from: connectedUsers.get(message[1]), pictureType: message[2] });\n" \
// " }\n" \
// " }\n" \
// "</script>" \
// "</head>" \
// "<body><noscript>Please enable JavaScript to test the libmicrohttpd Websocket chatserver demo!</noscript></body>" \
// "</html>"
#define PAGE_NOT_FOUND \
"404 Not Found"
+33 -33
View File
@@ -37,39 +37,39 @@
"<script>\n" \
"document.addEventListener('DOMContentLoaded', function() {\n" \
" const ws = new WebSocket('ws:// ' + window.location.host);\n" /* \
" const btn = document.getElementById('send');\n" \
" const msg = document.getElementById('msg');\n" \
" const log = document.getElementById('log');\n" \
" ws.onopen = function() {\n" \
" log.value += 'Connected\\n';\n" \
" };\n" \
" ws.onclose = function() {\n" \
" log.value += 'Disconnected\\n';\n" \
" };\n" \
" ws.onmessage = function(ev) {\n" \
" log.value += ev.data + '\\n';\n" \
" };\n" \
" btn.onclick = function() {\n" \
" log.value += '<You>: ' + msg.value + '\\n';\n" \
" ws.send(msg.value);\n" \
" };\n" \
" msg.onkeyup = function(ev) {\n" \
" if (ev.keyCode === 13) {\n" \
" ev.preventDefault();\n" \
" ev.stopPropagation();\n" \
" btn.click();\n" \
" msg.value = '';\n" \
" }\n" \
" };\n" \
"});\n" \
"</script>\n" \
"</head>\n" \
"<body>\n" \
"<input type='text' id='msg' autofocus/>\n" \
"<input type='button' id='send' value='Send' /><br /><br />\n" \
"<textarea id='log' rows='20' cols='28'></textarea>\n" \
"</body>\n" \
"</html>" */
// " const btn = document.getElementById('send');\n" \
// " const msg = document.getElementById('msg');\n" \
// " const log = document.getElementById('log');\n" \
// " ws.onopen = function() {\n" \
// " log.value += 'Connected\\n';\n" \
// " };\n" \
// " ws.onclose = function() {\n" \
// " log.value += 'Disconnected\\n';\n" \
// " };\n" \
// " ws.onmessage = function(ev) {\n" \
// " log.value += ev.data + '\\n';\n" \
// " };\n" \
// " btn.onclick = function() {\n" \
// " log.value += '<You>: ' + msg.value + '\\n';\n" \
// " ws.send(msg.value);\n" \
// " };\n" \
// " msg.onkeyup = function(ev) {\n" \
// " if (ev.keyCode === 13) {\n" \
// " ev.preventDefault();\n" \
// " ev.stopPropagation();\n" \
// " btn.click();\n" \
// " msg.value = '';\n" \
// " }\n" \
// " };\n" \
// "});\n" \
// "</script>\n" \
// "</head>\n" \
// "<body>\n" \
// "<input type='text' id='msg' autofocus/>\n" \
// "<input type='button' id='send' value='Send' /><br /><br />\n" \
// "<textarea id='log' rows='20' cols='28'></textarea>\n" \
// "</body>\n" \
// "</html>" */
#define BAD_REQUEST_PAGE \
"<html>\n" \
"<head>\n" \
+3 -3
View File
@@ -24,11 +24,11 @@ static const char base64_digits[] =
char *
BASE64Decode (const char*src)
BASE64Decode (const char *src)
{
size_t in_len = strlen (src);
char*dest;
char*result;
char *dest;
char *result;
if (in_len % 4)
{
+1 -1
View File
@@ -12,6 +12,6 @@
#include "platform.h"
char *
BASE64Decode (const char*src);
BASE64Decode (const char *src);
#endif /* !BASE64_H */
+2 -2
View File
@@ -1134,7 +1134,7 @@ get_date_string (char *date,
time_t t;
#if ! defined(HAVE_C11_GMTIME_S) && ! defined(HAVE_W32_GMTIME_S) && \
! defined(HAVE_GMTIME_R)
struct tm*pNow;
struct tm *pNow;
#endif
date[0] = 0;
@@ -2283,7 +2283,7 @@ socket_start_normal_buffering (struct MHD_Connection *connection)
if ( (0 != getsockopt (connection->socket_fd,
IPPROTO_TCP,
TCP_CORK,
(void*) &cork_val,
(void *) &cork_val,
&param_size)) ||
(0 != cork_val))
res &= (0 == setsockopt (connection->socket_fd,
+1 -1
View File
@@ -358,7 +358,7 @@ MHD_daemon_epoll_ (struct MHD_Daemon *daemon,
#endif
return MHD_SC_UNEXPECTED_EPOLL_WAIT_ERROR;
}
for (i = 0; i<(unsigned int) num_events; i++)
for (i = 0; i < (unsigned int) num_events; i++)
{
/* First, check for the values of `ptr` that would indicate
that this event is not about a normal connection. */
+3 -3
View File
@@ -72,7 +72,7 @@ struct MHD_IPCount
* @param daemon handle to a daemon
* @return master daemon handle
*/
static struct MHD_Daemon*
static struct MHD_Daemon *
get_master (struct MHD_Daemon *daemon)
{
while (NULL != daemon->master)
@@ -145,7 +145,7 @@ MHD_ip_addr_to_key (const struct sockaddr *addr,
/* IPv4 addresses */
if (sizeof (struct sockaddr_in) == addrlen)
{
const struct sockaddr_in *addr4 = (const struct sockaddr_in*) addr;
const struct sockaddr_in *addr4 = (const struct sockaddr_in *) addr;
key->family = AF_INET;
memcpy (&key->addr.ipv4,
@@ -158,7 +158,7 @@ MHD_ip_addr_to_key (const struct sockaddr *addr,
/* IPv6 addresses */
if (sizeof (struct sockaddr_in6) == addrlen)
{
const struct sockaddr_in6 *addr6 = (const struct sockaddr_in6*) addr;
const struct sockaddr_in6 *addr6 = (const struct sockaddr_in6 *) addr;
key->family = AF_INET6;
memcpy (&key->addr.ipv6,
+1 -1
View File
@@ -538,7 +538,7 @@ MHD_daemon_upgrade_connection_with_select_ (struct MHD_Connection *con)
/* FIXME: does this check really needed? */
if (MHD_INVALID_SOCKET != max_fd)
{
struct timeval*tvp;
struct timeval *tvp;
struct timeval tv;
if ( (con->tls_read_ready) &&
(urh->in_buffer_used < urh->in_buffer_size))
+1 -1
View File
@@ -48,7 +48,7 @@ MHD_itc_nonblocking_ (struct MHD_itc_ itc)
{
unsigned int i;
for (i = 0; i<2; i++)
for (i = 0; i < 2; i++)
{
int flags;
+6 -6
View File
@@ -37,7 +37,7 @@
* @param err the WinSock error code.
* @return pointer to string description of specified WinSock error.
*/
const char*
const char *
MHD_W32_strerror_winsock_ (int err)
{
switch (err)
@@ -277,12 +277,12 @@ MHD_W32_socket_pair_ (SOCKET sockets_pair[2], int non_blk)
listen_addr.sin_port = 0; /* same as htons(0) */
listen_addr.sin_addr.s_addr = htonl (INADDR_LOOPBACK);
if ( ((0 == bind (listen_s,
(struct sockaddr*) &listen_addr,
(struct sockaddr *) &listen_addr,
c_addinlen)) &&
(0 == listen (listen_s,
1) ) &&
(0 == getsockname (listen_s,
(struct sockaddr*) &listen_addr,
(struct sockaddr *) &listen_addr,
&addr_len))) )
{
SOCKET client_s = socket (AF_INET,
@@ -303,7 +303,7 @@ MHD_W32_socket_pair_ (SOCKET sockets_pair[2], int non_blk)
FIONBIO,
&on_val)) ||
( (0 != connect (client_s,
(struct sockaddr*) &listen_addr,
(struct sockaddr *) &listen_addr,
c_addinlen)) &&
(WSAGetLastError () != WSAEWOULDBLOCK)) )
{
@@ -315,7 +315,7 @@ MHD_W32_socket_pair_ (SOCKET sockets_pair[2], int non_blk)
addr_len = c_addinlen;
server_s = accept (listen_s,
(struct sockaddr*) &accepted_from_addr,
(struct sockaddr *) &accepted_from_addr,
&addr_len);
if (INVALID_SOCKET == server_s)
{
@@ -327,7 +327,7 @@ MHD_W32_socket_pair_ (SOCKET sockets_pair[2], int non_blk)
addr_len = c_addinlen;
if ( (0 == getsockname (client_s,
(struct sockaddr*) &client_addr,
(struct sockaddr *) &client_addr,
&addr_len)) &&
(accepted_from_addr.sin_family == client_addr.sin_family) &&
(accepted_from_addr.sin_port == client_addr.sin_port) &&
+1 -1
View File
@@ -533,7 +533,7 @@ typedef int MHD_SCKT_SEND_SIZE_;
* @param err the WinSock error code.
* @return pointer to string description of specified WinSock error.
*/
const char*MHD_W32_strerror_winsock_ (int err);
const char *MHD_W32_strerror_winsock_ (int err);
#endif /* MHD_WINSOCK_SOCKETS */
+2 -2
View File
@@ -775,9 +775,9 @@ MHD_str_to_uvalue_n_ (const char *str,
if (i)
{
if (8 == val_size)
*(uint64_t*) out_val = res;
*(uint64_t *) out_val = res;
else if (4 == val_size)
*(uint32_t*) out_val = (uint32_t) res;
*(uint32_t *) out_val = (uint32_t) res;
else
return 0;
}
+2 -2
View File
@@ -294,7 +294,7 @@ named_thread_starter (void *data)
*/
int
MHD_create_named_thread_ (MHD_thread_handle_ID_ *thread,
const char*thread_name,
const char *thread_name,
size_t stack_size,
MHD_THREAD_START_ROUTINE_ start_routine,
void *arg)
@@ -354,7 +354,7 @@ MHD_create_named_thread_ (MHD_thread_handle_ID_ *thread,
if (! MHD_create_thread_ (thread,
stack_size,
&named_thread_starter,
(void*) param))
(void *) param))
{
free (param);
return 0;
+1 -1
View File
@@ -227,7 +227,7 @@ MHD_create_thread_ (MHD_thread_handle_ID_ *thread,
*/
int
MHD_create_named_thread_ (MHD_thread_handle_ID_ *thread,
const char*thread_name,
const char *thread_name,
size_t stack_size,
MHD_THREAD_START_ROUTINE_ start_routine,
void *arg);
+1 -1
View File
@@ -156,7 +156,7 @@ static const char *const five_hundred[] = {
struct MHD_Reason_Block
{
size_t max;
const char *const*data;
const char *const *data;
};
#define BLOCK(m) { (sizeof(m) / sizeof(char*)), m }
+1 -1
View File
@@ -125,7 +125,7 @@ file_reader (void *cls,
f_ol.Offset = pos_uli.LowPart;
f_ol.OffsetHigh = pos_uli.HighPart;
if (! ReadFile (fh,
(void*) buf,
(void *) buf,
toRead,
&resRead,
&f_ol))
+1 -1
View File
@@ -64,7 +64,7 @@ tfind (const void *vkey, /* key to be found */
void *const *vrootp, /* address of the tree root */
int (*compar)(const void *, const void *))
{
node_t *const *rootp = (node_t *const*) vrootp;
node_t *const *rootp = (node_t *const *) vrootp;
if (NULL == rootp)
return NULL;
+11 -11
View File
@@ -15,21 +15,21 @@ extern "C" {
void *
tdelete (const void *__restrict,
void **__restrict,
int (*)(const void *, const void *));
void *
tfind (const void *,
void *const *,
tdelete (const void *__restrict,
void **__restrict,
int (*)(const void *, const void *));
void *
tsearch (const void *,
void **,
int (*)(const void *, const void *));
tfind (const void *,
void *const *,
int (*)(const void *, const void *));
void *
tsearch (const void *,
void **,
int (*)(const void *, const void *));
#if defined(__cplusplus)
};
+1 -1
View File
@@ -128,7 +128,7 @@ iovec_ahc (void *cls,
iov[j].iov_len = TESTSTR_SIZE / TESTSTR_IOVCNT;
for (i = 0; i < (int) (TESTSTR_IOVLEN / sizeof(int)); ++i)
((int*) iov[j].iov_base)[i] = i + (j * TESTSTR_IOVLEN / sizeof(int));
((int *) iov[j].iov_base)[i] = i + (j * TESTSTR_IOVLEN / sizeof(int));
}
response = MHD_create_response_from_iovec (iov,
+1 -1
View File
@@ -55,7 +55,7 @@ query_session_ahc (void *cls, struct MHD_Connection *connection,
if (NULL == *ptr)
{
*ptr = (void*) &query_session_ahc;
*ptr = (void *) &query_session_ahc;
return MHD_YES;
}
+3 -3
View File
@@ -132,11 +132,11 @@ load_keys (const char *hostname,
*/
static int
sni_callback (gnutls_session_t session,
const gnutls_datum_t*req_ca_dn,
const gnutls_datum_t *req_ca_dn,
int nreqs,
const gnutls_pk_algorithm_t*pk_algos,
const gnutls_pk_algorithm_t *pk_algos,
int pk_algos_length,
gnutls_pcert_st**pcert,
gnutls_pcert_st **pcert,
unsigned int *pcert_length,
gnutls_privkey_t *pkey)
{
+1 -1
View File
@@ -61,5 +61,5 @@ has_in_name (const char *prog_name, const char *marker)
}
if (name_pos == pos)
return 0;
return strstr (prog_name + name_pos, marker) != (char*) 0;
return strstr (prog_name + name_pos, marker) != (char *) 0;
}
+8 -8
View File
@@ -188,7 +188,7 @@ thread_gets (void *param)
CURL *c;
CURLcode errornum;
unsigned int i;
char *const url = (char*) param;
char *const url = (char *) param;
c = curl_easy_init ();
curl_easy_setopt (c, CURLOPT_URL, url);
@@ -237,7 +237,7 @@ do_gets (void *param)
port);
for (j = 0; j < PAR; j++)
{
if (0 != pthread_create (&par[j], NULL, &thread_gets, (void*) url))
if (0 != pthread_create (&par[j], NULL, &thread_gets, (void *) url))
{
for (j--; j >= 0; j--)
pthread_join (par[j], NULL);
@@ -247,7 +247,7 @@ do_gets (void *param)
for (j = 0; j < PAR; j++)
{
char *ret_val;
if ((0 != pthread_join (par[j], (void**) &ret_val)) ||
if ((0 != pthread_join (par[j], (void **) &ret_val)) ||
(NULL != ret_val) )
err = ret_val;
}
@@ -289,7 +289,7 @@ testInternalGet (int port, int poll_flag)
port = (int) dinfo->port;
}
start_timer ();
ret_val = do_gets ((void*) (intptr_t) port);
ret_val = do_gets ((void *) (intptr_t) port);
if (! ret_val)
stop (test_desc);
MHD_stop_daemon (d);
@@ -340,7 +340,7 @@ testMultithreadedGet (int port, int poll_flag)
port = (int) dinfo->port;
}
start_timer ();
ret_val = do_gets ((void*) (intptr_t) port);
ret_val = do_gets ((void *) (intptr_t) port);
if (! ret_val)
stop (test_desc);
MHD_stop_daemon (d);
@@ -389,7 +389,7 @@ testMultithreadedPoolGet (int port, int poll_flag)
port = (int) dinfo->port;
}
start_timer ();
ret_val = do_gets ((void*) (intptr_t) port);
ret_val = do_gets ((void *) (intptr_t) port);
if (! ret_val)
stop (test_desc);
MHD_stop_daemon (d);
@@ -437,7 +437,7 @@ testExternalGet (int port)
port = (int) dinfo->port;
}
if (0 != pthread_create (&pid, NULL,
&do_gets, (void*) (intptr_t) port))
&do_gets, (void *) (intptr_t) port))
{
MHD_stop_daemon (d);
return 512;
@@ -489,7 +489,7 @@ testExternalGet (int port)
stop ("external select");
MHD_stop_daemon (d);
if ((0 != pthread_join (pid, (void**) &ret_val)) ||
if ((0 != pthread_join (pid, (void **) &ret_val)) ||
(NULL != ret_val) )
{
fprintf (stderr,
+8 -8
View File
@@ -273,7 +273,7 @@ createListeningSocket (int *pport)
externalErrorExitDesc ("socket() failed");
#ifdef MHD_POSIX_SOCKETS
setsockopt (skt, SOL_SOCKET, SO_REUSEADDR, (void*) &on, sizeof (on));
setsockopt (skt, SOL_SOCKET, SO_REUSEADDR, (void *) &on, sizeof (on));
/* Ignore possible error */
#endif /* MHD_POSIX_SOCKETS */
@@ -281,7 +281,7 @@ createListeningSocket (int *pport)
sin.sin_family = AF_INET;
sin.sin_port = htons (*pport);
sin.sin_addr.s_addr = htonl (INADDR_LOOPBACK);
if (0 != bind (skt, (struct sockaddr*) &sin, sizeof(sin)))
if (0 != bind (skt, (struct sockaddr *) &sin, sizeof(sin)))
externalErrorExitDesc ("bind() failed");
if (0 != listen (skt, SOMAXCONN))
@@ -370,7 +370,7 @@ doAcceptAndAddConn (void *param)
(void) doAcceptAndAddConnInThread (p);
return (void*) p;
return (void *) p;
}
@@ -381,7 +381,7 @@ startThreadAddConn (struct addConnParam *param)
param->result = eMarker;
if (0 != pthread_create (&param->addConnThread, NULL, &doAcceptAndAddConn,
(void*) param))
(void *) param))
externalErrorExitDesc ("pthread_create() failed");
}
@@ -391,7 +391,7 @@ finishThreadAddConn (struct addConnParam *param)
{
struct addConnParam *result;
if (0 != pthread_join (param->addConnThread, (void**) &result))
if (0 != pthread_join (param->addConnThread, (void **) &result))
externalErrorExitDesc ("pthread_join() failed");
if (param != result)
@@ -520,7 +520,7 @@ doCurlQueryInThread (struct curlQueryParams *p)
static void *
doCurlQuery (void *param)
{
struct curlQueryParams *p = (struct curlQueryParams*) param;
struct curlQueryParams *p = (struct curlQueryParams *) param;
(void) doCurlQueryInThread (p);
@@ -535,7 +535,7 @@ startThreadCurlQuery (struct curlQueryParams *param)
param->queryError = eMarker;
if (0 != pthread_create (&param->queryThread, NULL, &doCurlQuery,
(void*) param))
(void *) param))
externalErrorExitDesc ("pthread_create() failed");
}
@@ -545,7 +545,7 @@ finishThreadCurlQuery (struct curlQueryParams *param)
{
struct curlQueryParams *result;
if (0 != pthread_join (param->queryThread, (void**) &result))
if (0 != pthread_join (param->queryThread, (void **) &result))
externalErrorExitDesc ("pthread_join() failed");
if (param != result)
+1 -1
View File
@@ -62,7 +62,7 @@
#define MHD_CPU_COUNT 2
#endif
#define TESTSTR "/* DO NOT CHANGE THIS LINE */"
#define TESTSTR " /* DO NOT CHANGE THIS LINE */ "
static int oneone;
+1 -1
View File
@@ -189,7 +189,7 @@ testRunWaitGet (int port, int poll_flag)
}
if (0 != pthread_create (&get_tid, NULL,
&thread_gets, (void*) (intptr_t) port))
&thread_gets, (void *) (intptr_t) port))
_exit (99);
/* As another thread sets "done" flag after ending of network
+2 -2
View File
@@ -62,7 +62,7 @@ struct CBC
size_t size;
};
char*
char *
alloc_init (size_t buf_size)
{
static const char template[] =
@@ -145,7 +145,7 @@ ahc_echo (void *cls,
processed = 0;
*pparam = &processed; /* Safe as long as only one parallel request served. */
}
pproc = (size_t*) *pparam;
pproc = (size_t *) *pparam;
if (0 == *upload_data_size)
return MHD_YES; /* No data to process. */