* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2012, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
- * are also available at http://curl.haxx.se/docs/copyright.html.
+ * are also available at https://curl.haxx.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
if(mention)
fprintf(stderr, "Remove socket fd %d\n", (int) fd);
- for (i = 0; i < sockets->count; ++i) {
- if (sockets->sockets[i] == fd) {
- if (i < sockets->count - 1)
+ for(i = 0; i < sockets->count; ++i) {
+ if(sockets->sockets[i] == fd) {
+ if(i < sockets->count - 1)
memmove(&sockets->sockets[i], &sockets->sockets[i + 1],
sizeof(curl_socket_t) * (sockets->count - (i + 1)));
--sockets->count;
(void)easy; /* unused */
(void)socketp; /* unused */
- if (action == CURL_POLL_IN || action == CURL_POLL_INOUT)
+ if(action == CURL_POLL_IN || action == CURL_POLL_INOUT)
addFd(&sockets->read, s, "read");
- if (action == CURL_POLL_OUT || action == CURL_POLL_INOUT)
+ if(action == CURL_POLL_OUT || action == CURL_POLL_INOUT)
addFd(&sockets->write, s, "write");
if(action == CURL_POLL_REMOVE) {
struct timeval* timeout = userp;
(void)multi; /* unused */
- if (timeout_ms != -1) {
+ if(timeout_ms != -1) {
*timeout = tutil_tvnow();
timeout->tv_usec += timeout_ms * 1000;
}
CURLMsg* message;
int result = 0;
*success = 0;
- while ((message = curl_multi_info_read(curl, &numMessages)) != NULL) {
- if (message->msg == CURLMSG_DONE) {
+ while((message = curl_multi_info_read(curl, &numMessages)) != NULL) {
+ if(message->msg == CURLMSG_DONE) {
result = 1;
- if (message->data.result == CURLE_OK)
+ if(message->data.result == CURLE_OK)
*success = 1;
else
*success = 0;
now = tutil_tvnow();
result = (timeout->tv_sec - now.tv_sec) * 1000000 +
timeout->tv_usec - now.tv_usec;
- if (result < 0)
+ if(result < 0)
result = 0;
return curlx_sztosi(result);
curl_socket_t *maxFd)
{
int i;
- for (i = 0; i < sockets->count; ++i) {
+ for(i = 0; i < sockets->count; ++i) {
FD_SET(sockets->sockets[i], fdset);
- if (*maxFd < sockets->sockets[i] + 1) {
+ if(*maxFd < sockets->sockets[i] + 1) {
*maxFd = sockets->sockets[i] + 1;
}
}
{
int numhandles = 0;
CURLMcode result = curl_multi_socket_action(curl, s, evBitmask, &numhandles);
- if (result != CURLM_OK) {
+ if(result != CURLM_OK) {
fprintf(stderr, "Curl error on %s: %i (%s)\n",
info, result, curl_multi_strerror(result));
}
int evBitmask, const char *name)
{
int i;
- for (i = 0; i < sockets->count; ++i) {
- if (FD_ISSET(sockets->sockets[i], fdset)) {
+ for(i = 0; i < sockets->count; ++i) {
+ if(FD_ISSET(sockets->sockets[i], fdset)) {
notifyCurl(curl, sockets->sockets[i], evBitmask, name);
}
}
int res = 0;
CURL *curl = NULL;
FILE *hd_src = NULL;
- int hd ;
+ int hd;
int error;
struct_stat file_info;
CURLM *m = NULL;
start_test_timing();
- if (!libtest_arg3) {
+ if(!libtest_arg3) {
fprintf(stderr, "Usage: lib582 [url] [filename] [username]\n");
return TEST_ERR_USAGE;
}
easy_setopt(curl, CURLOPT_UPLOAD, 1L);
/* specify target */
- easy_setopt(curl,CURLOPT_URL, URL);
+ easy_setopt(curl, CURLOPT_URL, URL);
/* go verbose */
easy_setopt(curl, CURLOPT_VERBOSE, 1L);
multi_add_handle(m, curl);
- while (!checkForCompletion(m, &success))
- {
+ while(!checkForCompletion(m, &success)) {
fd_set readSet, writeSet;
curl_socket_t maxFd = 0;
struct timeval tv = {10, 0};
updateFdSet(&sockets.read, &readSet, &maxFd);
updateFdSet(&sockets.write, &writeSet, &maxFd);
- if (timeout.tv_sec != -1)
- {
+ if(timeout.tv_sec != -1) {
int usTimeout = getMicroSecondTimeout(&timeout);
tv.tv_sec = usTimeout / 1000000;
tv.tv_usec = usTimeout % 1000000;
}
- else if (maxFd <= 0)
- {
+ else if(maxFd <= 0) {
tv.tv_sec = 0;
tv.tv_usec = 100000;
}
checkFdSet(m, &sockets.read, &readSet, CURL_CSELECT_IN, "read");
checkFdSet(m, &sockets.write, &writeSet, CURL_CSELECT_OUT, "write");
- if (timeout.tv_sec != -1 && getMicroSecondTimeout(&timeout) == 0)
- {
+ if(timeout.tv_sec != -1 && getMicroSecondTimeout(&timeout) == 0) {
/* Curl's timer has elapsed. */
notifyCurl(m, CURL_SOCKET_TIMEOUT, 0, "timeout");
}
abort_on_test_timeout();
}
- if (!success)
- {
+ if(!success) {
fprintf(stderr, "Error uploading file.\n");
res = TEST_ERR_MAJOR_BAD;
}